I run OS/X on my personal machine and Linux on my remote servers. (I could never afford an Xserve even back when they still made 'em.) I'd love to use the same .bashrc file for both and I want to have ls show me colors so I can identify executable files, directories, and the like.
But the GNU ls
on Linux wants to see the --colors
command line switch or it will refuse to show colors. Apple's (BSD?) ls
prefers to see the export CLICOLORS=1
shell variable to tell it to show colors.
I'd do both, but the Apple ls
barfs if it sees an unknown --colors
switch.
Is there are good way in .bashrc for me to detect whether ls
accepts a switch and then decide whether to alias it with --colors
or not?
brew install coreutils
... and then prepend/usr/local/Cellar/coreutils/*/libexec/gnubin
to your PATH. – muru Feb 03 '17 at 04:57