10

I don't know why my bash session doesn't show colors. I have tried Terminal as well as iTerm.

I have tried:

  1. ls -G
  2. Setting export CLICOLOR=1 and export LSCOLORS=GxFxCxDxBxegedabagaced
  3. Using different themes such as solarized and something else

The versions of my software are:

  1. bash: GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
  2. osx: 10.9.2

I have Homebrew installed

I don't know what other information might be helpful. I spend a lot of time on the shell, this problem is becoming very annoying :)

edit: in terminal preferences, I have 'Declare terminal as: xterm-256color' and 'Display ANSI colors' along with 'Use bright colors for bold text'

2
  • Try running printf '\e[32mtest\n', if that works then it's a problem with ls.
    – 0942v8653
    Commented Mar 26, 2014 at 20:47
  • I'm also having this problem. To extend what you've tried, the problem persists with coreutils' gls command. The comment above successfully changes the prompt color. My problem appears to be with the SolarizedDark theme, as changing the color in Terminal.app preferences in other themes works.
    – agweber
    Commented Sep 16, 2014 at 19:12

2 Answers 2

5

I would suggest installing the GNU Core Utilities via Homebrew, which will give you the "Linux" version of ls (instead of the FreeBSD version that ships with OS X), as well as other powerful tools

brew update
brew install coreutils

You should then be able to show colors with:

gls --color

Additionally, read the caveats to configure your PATH so you can use commands like gls with their normal names, i.e. ls:

$ brew info coreutils
coreutils: stable 8.23 (bottled)
https://www.gnu.org/software/coreutils
Conflicts with: ganglia, idutils
/usr/local/Cellar/coreutils/8.23 (214 files, 10M)
  Poured from bottle
/usr/local/Cellar/coreutils/8.23_1 (214 files, 10M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/coreutils.rb
==> Dependencies
Build: xz ✔
==> Caveats
All commands have been installed with the prefix 'g'.

If you really 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"

Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:

    MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"
2
  • It's worth noting that gls (GNU ls) does not enable color by simply defining the CLICOLOR environment variable as the default BSD ls command from OS X does. Also, the -G switch to enable color in BSD ls doesn't work for GNU ls nor does --color work for BSD ls. You HAVE to define an alias for ls to add the --color switch if you want all your ls commands colorized. For reference from "man ls" (BSD flavor): "-G Enable colorized output. This option is equivalent to defining CLICOLOR in the environment." Commented Nov 1, 2015 at 16:53
  • Using gls --color after installing coreutils I got default coloring, not the colors from my LSCOLORS var. Since I'd munged my path to default to the gnu tools by their usual names I just did rm which ls to go back to /bin/ls which worked fine. Surprisingly this pissed off the current shell, which couldn't find ls anymore, but new shells worked fine. bash doesn't have a rehash, so I don't understand why it got hung up on /usr/local/opt/coreutils/libexec/gnubin/ls Commented Jul 11, 2016 at 22:50
2

In Temrinal's Terminal > Preferences select the profile for the session type you're using and check under the Advanced tab what terminal declaration you're using. Most likely the one selected doesn't support ANSI coloring. xterm-256color should support what you're expecting.

1
  • I just checked, terminal is already set to xterm-256color (updated question to reflect this and other info)
    – Shahbaz
    Commented Mar 21, 2014 at 1:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .