Colors in Terminal.app

If you’ve used Terminal.app, you’d notice that it’s a bit boring that their linux counterparts due to the lack of file and directory colors. Adding 2 lines in your ~/.bash_profile file will add a little color to your boring Terminal.

Open ~/.bash_profile, using vi or vim or whatever, and add these two lines:
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

Save the file, quit Terminal, open it again, then do an “ls”. You now have file and directory colors/highlights enabled!

If you want to change to a different color, note the 2nd line you added. Each pair of characters denotes the foreground color and background color for a specific type of file or directory. For example, the first pair, “Ex” means that the foreground color is “E” (which is Bold Blue) and the background is “x” (which is the default background set by Terminal preferences).

Here are the order of pairs in the LSCOLORS parameter:
  1. Directory
  2. Symbolic link
  3. Socket
  4. Pipe
  5. Executable
  6. Block special
  7. Character special
  8. Executable with setuid bit set
  9. Executable with setgid bit set
  10. Directory writable to others, with sticky bit
  11. Directory writable to others, without sticky bit

And here’s the list of available colors:
  • a  black
  • b  red
  • c  green
  • d  brown
  • e  blue
  • f  magenta
  • c  cyan
  • h  light grey
  • A  block black, usually shows up as dark grey
  • B  bold red
  • C  bold green
  • D  bold brown, usually shows up as yellow
  • E  bold blue
  • F  bold magenta
  • G  bold cyan
  • H  bold light grey; looks like bright white
  • x  default foreground or background

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.