I have a Z-shell configuration that I use on multiple servers and my personal computer. On my personal computer I have an alias to an executable we will call foo. Here is the line in my zshrc to alias to this program:
alias foo=/path/to/foo
On several servers the path to foo is different and I can not move it to a common directory like ~/bin:
alias foo=/sever/path/to/foo
I need the alias to be foo on all machines, so I cannot create two seperate alias like foo and foo-server for example. Is there a way to have the Z-shell detect what machine I am on and change the alias to foo automatically? Naively, something like:
if on personal computer:
alias foo=/path/to/foo
else:
alias foo=/sever/path/to/foo
For anyone else that comes across this, the best solution I could find is:
Thanks to larsmans for suggesting the
-xflag