Bash color shell on Mac?
Solution 1:
To turn on colour output from the ls
command without having to create an alias to ls
or download any additional software, add the following to your ~/.bash_profile
:
# Terminal colours
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
If you don't like those colours you can use this ls color generator to customize that color list to your liking.
You'll need to do:
source ~/.bash_profile
After making any changes for them to take effect in your existing shell.
Solution 2:
The problem is that OS X doesn't have GNU ls
; while its ls
does support file name coloring, it can only do so by the type of file (file, directory, symlink, device special file, fifo, socket...). Install coreutils
from Fink/MacPorts/HomeBrew, then use alias ls='gls --color=auto'
.
Solution 3:
BSD ls works a bit differently
alias ls='ls -G'
should work.
And this isn't bash coloring, it is ls
doing the colorization. When bash does a file list (try echo *
in a directory) there is no way to colorize. Typing ls -G
would work in any shell, though a shell (like bash) that has aliases makes it easier.
Solution 4:
On the Mac, you need to use
export CLICOLOR=1
I put that in the .bash_profile. However, I prefer Rich Homolka's solution to alias ls with -G flag. If you want to customize the colors:
man ls
and search for LSCOLORS