How do I colorize the ls
command in fish? I am using ITerm2 on Mac with appropriate fonts etc. For some reason it stopped working on my computer. When I do the recommended
function ls
command ls --color=auto $argv
end
I get that the --color command is not recognized ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
I thought it might be due to installing gnucoreutils and writing over fish's ls command, but removing it did not seem to help. When I do ls -G via alias, I can get colorized output for folders for a session, but it resets at end of session back to the original. Any idea what might be the problem?
The /bin/ls command on macOS has different options than the GNU Linux version. Replace --color=auto
with -G
. Alternatively, install the GNU version using Homebrew to install the "coreutils" package. Then invoke it as gls
.