Always use a different name for your alias. For example (one of mine):
alias ipex='curl -s http://ipecho.net/plain'
Or, in your case:
alias s4='sshfs 10.xxx.xx.4:/Users/username/code mountpoint'
alias s8='sshfs 10.xxx.xx.8:/Users/username/code mountpoint'
and so on.
You may use more complex aliases, or even personal functions used inside aliases, for example when you need to pass a parameter inside the command, not at the end (as to provide a changing IP address to your alias), but it is probably a bit too much depending on your question.
Anyway, this is one of mine, again:
# Delete an existing alias, but only if it exists in order to avoid an error:
dont_alias() {
alias $1 >/dev/null 2>&1 && unalias $1
return $?
} # dont_alias
Then I use dont_alias as an alias, for example:
dont_alias s4 # Will unalias the existing s4
dont_alias s7 # Will do nothing
The only difference with aliases is that functions do not appear in the list of (existing) aliases.
I have a few more complex samples (that I use daily), if some people are interested. Please feel free to ask for — I do my best to come here every few days :^)
sshfs 10.xxx.xx.4:/Users/username/code mountpoint
, it expands the alias and winds up trying to runsshfs 10.xxx.xx.4:/Users/username/code mountpoint 10.xxx.xx.4:/Users/username/code mountpoint
, and the extra arguments causesshfs
to complain. You need to name the alias something different from the command to avoid this confusion. – Gordon Davisson Oct 17 '19 at 23:07