Closed rhodesch closed 10 months ago
Thanks, good point and thanks for the fix.
I'm not sure I want to introduce this additional complexity. The solution here strictly requires the conda installation location to be correct (which is likely to change yet again as conda now includes libmamba) and requires coreutils to have been installed. And all of this happens at setup time.
After going down a bit of a rabbit hole just now, I found out that to configure colors for the BSD ls
, you can use LSCOLORS
. This is from the man page but also https://superuser.com/a/1746907 which refers to https://geoff.greer.fm/lscolors. That latter web tool takes both dircolors
(Linux LS_COLORS
, note the underscore) as well as BSD LSCOLORS
(no underscore).
It turns out you can largely match dircolors with built-in /bin/ls
: first activate an env with dircolors (e.g., ca
), then run dircolors
, then paste the value of dircolors-reported LS_COLORS
into that web tool. It reports that the LSCOLORS
equivalent is exGxBxDxCxEgEdxbxgxcxd
.
So if you do export LSCOLORS=exGxBxDxCxEgEdxbxgxcxd
and then /bin/ls -G
, the colors look reasonable.
I noticed that the web tool wasn't making directories bold like dircolors was, so I changed it to export LSCOLORS=ExGxBxDxCxEgEdxbxgxcx
(note capital "E" at the beginning).
That is, in .aliases
, use:
if [[ $OSTYPE == darwin* ]]; then
export LSCOLORS=ExGxBxDxCxEgEdxbxgxcxd
alias ls='/bin/ls -G'
else
if [ `command -v dircolors` ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
fi
alias ls='ls --color=auto'
fi
The main limitation here is that some colors created from the more complete dircolors
configuration do not show up in a different color. For me, most notably that means compressed files and image files don't show up in a different color.
So I think the decision boils down to, "are the colors of other files (like compressed files and images) important?".
If not, then I think exporting LSCOLORS
makes the ls
output mostly similar to coreutils ls
and fixes #33. If colors of other files are important, we should continue looking for a good solution here.
I could go either way, but currently leaning towards simplicity and solving 80% of the problem with LSCOLORS
.
Thoughts?
Thanks - I also prefer your option, which fixes #33
Updating the conditional block in .aliases
with your code above makes colors mostly consistent, which seems more important than colorizing all files. Completely agree that it's best to avoid requiring conda installation location to be correct.
If the related issue and this PR are not closed by end of week, I can close.
Thanks for the discussion, this is now addressed in #36.
See #33. On macos with coreutils installed into base conda environment, minor changes to files to improve ls color consistency.
Tested conditions:
Follow .setup.sh RECOMMENDED ORDER with minimal changes:
old ls behavior on mac (not tested on linux):
new ls behavior on mac and linux: