Reputation: 880
I'm new to OS X and also other Linux distributions(Ubuntu, CentOS, RHEL) user.
I want to know why OS X's bash can not use --color=auto
option and how to enable it.
I often use ls --color=auto
, but on OS X, it doesn't work. The following is the command output:
$ ls --color=auto
ls: illegal option -- -
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
I also read man page of ls
, and I found ls -G
is enabler of colorized output.
So, at this time, it's okay, but I'm a little bit annoying because I'm sharing the .bashrc
and .bash_profile
for all my linux environments.
Does anyone know these bash's different? And do you have any good idea to share the .bashrc
and .bash_profile
between OS X and some linux distributions without additional edit on each environment.
P.S.
My friend tells me bash on AIX(Linux server IBM version? I'm not sure) could not run ls --color=auto
also.
Upvotes: 2
Views: 1259
Reputation: 11
Use homebrew
to install GNU coreutils
:
brew install coreutils
export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
useful link:https://github.com/sorin-ionescu/prezto/issues/966
Upvotes: 0
Reputation: 9065
The implementation of ls
command and other commands like ps
and top
is different, most utils have a GNU version and BSD version. Linux take the GNU version while OSX may take a BSD version, so options for those commands may differ.
if you want to make a .bashrc
or .bash_profile
that works everywhere, you should judge the environment before you alias your command like:
_myos="$(uname)"
case $_myos in
Linux) alias ls='ls --color';;
Darwin) alias ls='ls -G';;
*) ;;
esac
Upvotes: 8