Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

How can I configure Mac Terminal to have color ls output? I am using MacOS 10.5

share|improve this question

migrated from stackoverflow.com Dec 14 '11 at 4:40

This question came from our site for professional and enthusiast programmers.

3  
This is a great question... I've always expected ls --color (a la gnu ls) to just work everywhere. MacOS doesn't accept --color, so I assumed that it didn't have colored output as an option at all. –  Armentage May 1 '11 at 16:35

6 Answers 6

Edit:

~/.bash_profile

or

~/.profile

and add the following two lines:

export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

you can use this if you are using a black background:

export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
share|improve this answer
14  
Or gxBxhxDxfxhxhxhxhxcxcx on black background –  Mikulas Dite Jul 16 '10 at 17:51
5  
I'm using LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd" to emulate the default colouring on the linux ls command –  Jamie Cook Dec 21 '13 at 13:52
    
Thanks Jamie, this is just what I needed, I really wanted to keep default colouring. –  janko-m Mar 10 at 16:48

You can add

alias ls='ls -G'

to your ~/.bash_profile to get colored ls output.

share|improve this answer
20  
Mine is alias ls="ls -Gp" — the -p adds a slash after each directory. For me, it provides that much more visual differentiation, which is helpful. –  Quinn Taylor Jun 12 '09 at 15:40
22  
I see your -p and raise you a -F which in addition puts an * after executables, | after pipes, @ after symlinks, et cetera. –  aib Dec 27 '10 at 18:57
12  
Just for fun, throw in a -h, which will format sizes in "human readable" units, i.e. 100b 10k, 23m, 4.2g –  Armentage May 1 '11 at 16:29
2  
If you don't have a .bash_profile already at ~/.bash_profile, be sure to source it, so that it will work. Do this with "source ~/.bash_profile" –  y3sh Jul 28 '11 at 18:00

If you want a readable mac os x terminal color scheme, you may want to look into this:

http://toddwerth.com/2008/01/25/a-black-os-x-leopard-terminal-theme-that-is-actually-readable/

and the version for Lion:

http://toddwerth.com/2011/07/21/the-original-ir_black-for-os-x-lion/

I've been using this for over a year now, and I might not be able to function without it!

share|improve this answer
4  
As of Mac OS X Lion 10.7, Terminal allows customizing the ANSI colors, so using SIMBL or other extensions is no longer necessary. It also supports 256 colors. –  Chris Page Sep 4 '11 at 8:59

Another option is to use the GNU ls which is part of the 'coreutils' program.

You can get it via Rudix or Homebrew (brew info coreutils)or Macports or Fink. That might be preferable to using a "Mac OS X-only" solution if you use the same shell config files on different systems, or are already familiar with GNU ls.

share|improve this answer

Also you can customize the prompt color (and its format) by adding:

PS1='\[\e[0;33m\]\h:\W \u\$\[\e[m\] '

to ~/.bash_profile or ~/.profile file. Where 0;33 is regular yellow which looks nice in my black/semitransparent terminal window.

Here is a full list of colors and their explanations: https://wiki.archlinux.org/index.php/Color_Bash_Prompt

My awesome terminal window

share|improve this answer
    
It's useful! Thx! –  Kjuly Sep 16 '12 at 8:23

Forget all those decades-old cryptic codes for gosh sakes, use the built in Terminal --> Preferences... Settings pane to set the default skin, and edit the ANSI colors to your liking. You can set the font, too. I prefer Menlo 12pt. This is how any regular Joe can do it, and avoid all the crazy command-line, unix-esque way of doing things as other posters have suggested.

share|improve this answer
5  
I think anybody experienced enough to even know that ls can have colored output is also able to run a few Unix commands to configure it correctly. –  patrix Sep 21 '12 at 21:35
1  
+1 for pretty much perfect irony. –  Dan J Sep 21 '12 at 22:02
4  
But this just makes ls show in one colour it does not make links, directories, files show in different colours as ls can do –  Mark Sep 25 '12 at 12:29
1  
@geoffhoffman be trollin' yall –  Jamie Cook Dec 21 '13 at 13:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.