trapd00r/LS_COLORS

not working on mac in Fish shell

mals14 opened this issue · 11 comments

Coloring ls output looks great. Thanks for putting this together.

Am unable to make it work however.
Using Mac - 10.14.2.
Fish shell - fish, version 3.0.0

carried out this command.
wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O $HOME/.dircolors

then added
eval ( dircolors --c-shell $HOME/LS_COLORS ) to config.fish in ~/.config/fish

but receiving this error

eval ( dircolors --c-shell $HOME/LS_COLORS )
fish: Unknown command 'dircolors'
fish:
 dircolors --c-shell $HOME/LS_COLORS
 ^
in command substitution
	called on standard input

I looked up solutions to this but none seems to work.

  1. Tried brew install coreutils per recommendation here #3

Tried to run gls after installing coreutils but no glorious colors :(

  1. Changed the command to refer to $HOME/.dircolors
eval ( dircolors --c-shell $HOME/.dircolors )
fish: Unknown command 'dircolors'
fish:
 dircolors --c-shell $HOME/.dircolors
 ^
in command substitution
	called on standard input

Any suggestions? Thank you!

After installing coreutils via homebrew, the following warning is printed:

==> Caveats
Commands also provided by macOS have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
  PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

Please comment again if this isn't what you need.

Hi - thanks for replying.
So, I did try gls, but that did not colorize the output either.

I am using Fish shell and on a Mac.
Have saved the $HOME/.dircolors file as the wget instruction does.

However, neither in bash shell nor in fish shell, can I make this work.
the eval $(dircolors -b $HOME/.dircolors) command does not work even on the bash shell on my computer.
This is what I get:

bash-5.0$ eval $(dircolors -b $HOME/.dircolors)
bash: dircolors: command not found

The problem isn't ls vs gls. Rather, it's dircolors vs gdircolors. As the warning explains, dircolors will not be in the PATH unless you add /usr/local/opt/coreutils/libexec/gnubin to the PATH.

Got it. I did that. I did that and now the eval dircolors command does through.

For Fish shell,
eval ( dircolors --c-shell $HOME/.dircolors )
completed without error. Or at least did not generate an error message.

And then I tried ls again.
And no colors.

Any other investigation that I could do?

In fact, the Mac /bin/ls used to do some basic colors. Even those colors have stopped appearing with the coreutils ls.

I wonder if it has anything to do with iTerm2 that I am using. But then I tried it in Terminal also. And no luck. No colors. :(

Before this, ls output had minimal colors - directories were a different color, and I think I have colors based on chmod settings. That is with /bin/ls and may be because I have "oh-my-fish/theme-bobthefish" installed via fisher on Fish shell.

in the Fish shell, echo $LS_COLORS shows that LS_COLORS has been set. Still the coreutils ls which is now in the path due to the prepending of the coreutils path, does not show any colors.

which ls shows this /usr/local/opt/coreutils/libexec/gnubin/ls.
echo $LS_COLORS begins with bd=38;5;68:ca=38;5;17:cd=38;5;113;1:di=38;5;30:do=38;5;127:ex=38;5;208...

Any further clues to what I might be able to do to make it work?

/bin/ls -G does show some basic colors on the Mac, in the Fish shell in iTerm.

Does it work in bash? If it works in bash, then this is a question for fish dev channels.

ls does not produce colorized output without ls -G, as you noticed. That behavior should be independent of the shell.

It did not work in bash either. I was trying to test in both.

So as I searched online, it seems that I had to run this command
ls --color
and then the output of ls includes glorious color.

Thanks for helping me out!

So in summary, on a Mac, for Fish shell,

  1. brew install coreutils
  2. wget https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS -O $HOME/.dircolors
  3. set PATH "/usr/local/opt/coreutils/libexec/gnubin" $PATH
  4. eval ( dircolors --c-shell $HOME/.dircolors )
  5. And now every time, use ls --color. I think in Fish shell I need to setup a function to do this every time.

3 and 4 would be different for bash.

So last update here - fish already had a function for ls. When I removed that function, then I saw that ls alone produced colors.

TIL ls is a fish builtin. Wild

TIL ls is a fish builtin. Wild

Indeed!

Fish auto-completes and themes etc seemed interesting enough to switch from Bash to Fish. But the world lives in Bash and pros perhaps trick out Bash to do all that Fish does.