Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently storing most of my dotfiles in a git repository to make keeping them in sync across all my computers easier. I've just recently acquired a Macbook so now have to have all my dotfiles supporting the differences between Linux and Darwin. The first incompatability that I have encountered is colour coding ls, in Linux this is the flag --color=auto and for Darwin it is -G.

My first attempt at making my .zshrc portable is to do the following:

case `uname` in
    alias ls='ls -FG'
    alias ls='ls -F --color=auto'

Once I find a few more things to change I'll probably pull the computer specific stuff out to separate files to keep it a bit cleaner. What I'm mainly wondering is if there is a better way to do this other than using `uname` to determine which stuff to run.

share|improve this question

I used to use this mechanism:

if [ -r $envfile ]; then
    . $envfile
envfile="$HOME/.bash/host.`uname -n`.sh"
if [ -r $envfile ]; then
    . $envfile

Then I could rsync the .bash directory around to each machine as needed to keep all up to date.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .