Use nice colors for coloring files when LS_COLORS is not set.

This commit is contained in:
Andrew Hamilton 2016-01-22 12:49:43 +00:00
parent e9eb104d0d
commit 7c66d6959d
4 changed files with 752 additions and 2 deletions

View file

@ -69,7 +69,16 @@ _STATUS_TO_TERMSTR_SIMPLE[Status.error] = termstr.TermStr(
_STATUS_TO_TERMSTR_SIMPLE[Status.empty] = "."
LS_COLOR_CODES = lscolors.get_color_codes(os.environ)
def get_ls_color_codes():
if "LS_COLORS" not in os.environ:
script = os.path.join(os.path.dirname(__file__), "LS_COLORS.sh")
with open(script) as file_:
codes = file_.readline().strip()[len("LS_COLORS='"):-len("';")]
os.environ["LS_COLORS"] = codes
return lscolors.get_color_codes(os.environ)
LS_COLOR_CODES = get_ls_color_codes()
def fix_input(input_):