I'm trying to move my bash configuration from Ubuntu to Mac OS X and it looks like ls is slightly different. For instance, it won't accept the --color option.

How do I get this to work?

link|improve this question

feedback

3 Answers

up vote 9 down vote accepted

ls is actually separate from Bash. OS X has a BSD version of ls, which requires -G on the command line, or CLICOLOR (and perhaps LSCOLORS) in the environment.

See man ls for more info.

link|improve this answer
Ditto. I've alias ls='ls -G' set in my .bashrc on Snow Leopard. – ayaz Sep 2 '10 at 15:40
feedback

You'll need to install an alternate version of ls. The one usually used in linux is from the GNU coreutils project.

You could build and install or install from macports, fink or homebrew.

link|improve this answer
3  
That's overkill, in my opinion. You don't need to install a separate version of ls when the same feature is supported slightly differently on the existing version of ls. – ayaz Sep 2 '10 at 15:41
Good point. Then again, colored ls has never been my taste. alias ls='ls -F' – Doug Harris Sep 2 '10 at 17:37
alias ls='ls -FG' -- it's the best of both worlds! – mipadi Sep 2 '10 at 17:42
feedback

Use Homebrew.

brew install coreutils

Note that this will throw a prefix of 'g' in front of all the commans (ex. gls for ls). It gives an option to source a file that will alias these for you automatically.

I wasn't sure if there was an option to install them directly without having to do the whole alias thing, so instead in installed MacPorts and did this.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.