you can alias the command as follow :
alias sshDev="ssh -tp 22 username@ip_address 'cd /path/to/dir; bash'"
As Arthur2e5 suggested adding parameters -il
is convenient
related part in man bash
:
-i If the -i option is present, the shell is interactive.
-l Make bash act as if it had been invoked as a login shell (see INVOCATION below).
If you wish to have a dynamic destination folder (define it each time you call the alias) you will have to write a function called by your alias. E.g.:
alias sshDev=ssh·Dev
function ssh·Dev() {
if [ "$#" -eq 0 ]; then
fav_dir="/path/to/dir"
else
fav_dir=$1
fi
ssh -tp 22 username@ip_address "cd $fav_dir; bash"
}
With this little piece of code, when you call(type) the alias in your command line as follow: sshDev
(without parameters) , it will use the statical /path/to/dir defined in the function , otherwise if you call the alias like this sshDev /one/other/path/to/dir
will use the path provided in-line.
cd blah; exec bash -il
is better. – Mingye Wang Oct 15 '15 at 13:43