Use nice colors for coloring files when LS_COLORS is not set.
This commit is contained in:
parent
e9eb104d0d
commit
7c66d6959d
4 changed files with 752 additions and 2 deletions
11
tools.py
11
tools.py
|
|
@ -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_):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue