Skip to content

Instantly share code, notes, and snippets.

@alexjs
Created April 3, 2013 18:06
Show Gist options
  • Save alexjs/5303641 to your computer and use it in GitHub Desktop.
Save alexjs/5303641 to your computer and use it in GitHub Desktop.
zsh function to allow ssh'ing direct to a directory
ssh() {
# If we specify host:dir, ssh straight to that dir
if [[ $1 =~ "(.*):(.*)" ]]; then
host=${match[-2]}
path=${match[-1]}
/usr/bin/ssh -t $host "cd ${path} && exec ${SHELL}"
else
/usr/bin/ssh $*
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment