Up until this month, my shell configs have been pretty simple (just a .bashrc
or .bash_profile
with some aliases mainly), but I have been refactoring it so I can get different behavior depending on whether I'm using zsh, and bash. They first source a generic shell config file that should work for whatever, then specialize for the specific shell being used (I symlink to this).
I was surprised today when ls
stopped working. It turned out that during refactoring .bashrc
, there was an alias
alias ls='ls --color=always'
that was breaking things for ls
in bash on Terminal in OSX. Once I saw that BSD ls
likes -G
for color, but GNU (or whatever was on Ubuntu) likes --color
, it was clear that quite a few options differ.
My question is, what is the best way to account for differences in options and such between BSD and GNU coreutils? Should I test for an env variable in if
blocks to see what OS is being used and apply correct behavior? Or does it make more sense to make separate config files for each OS?
While answers to these questions may be subjective, it seems like a rundown of the scope of differences between BSD and GNU coreutils and strategies to work around these to make a generic config usable on most *nix would be fairly objective.
ls -c
is different fromls --color
. Edited your question to fix.