Command works when run from alias but not when typed? I use to type this command a lot :

sshfs 10.xxx.xx.4:/Users/username/code mountpoint


So one day i put it as an alias on my .bash_profile as

alias sshfs='sshfs 10.xxx.xx.4:/Users/username/code mountpoint'


and started to use the alias all the time

i have noticed that now after a few months if i copy/type the command directly into the terminal i get "Fuse: invalid argument" error but if i continue to use the alias it works fine.

What's going on here?
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 &gt;/dev/null 2&gt;&amp;1 &amp;&amp; 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 :^)