Create custom Terminal shortcuts I'm working a lot with SSH connections to servers, by for example forwarding localports or just establishing SSH connection to manage some servers.

For this I would like to be able to create some terminal shortcuts for example:

connect ssh server1
--&gt;should run command: ssh xyx@xy
connect ssh server2 forward
--&gt;should run command: ssh -NC user@xy -L 9999:localhost:3306


Is there a way to specify custom terminal commands?
Simply add aliases in ~/.bash_profile:

If the file .bash_profile doesn't exist:

touch ~/.bash_profile


Then add aliases with nano ~/.bash_profile. Examples:

alias ssh01='ssh xyx@xy'
alias ssh02='ssh -NC user@xy -L 9999:localhost:3306'


Then source the file or restart Terminal.app:

source ~/.bash_profile


Entering ssh01 in the shell will then execute ssh xyx@xy or ssh02 the second command.

The alias (i.e. ssh01) mustn't be another valid command in your path (e.g ssh-add)