Skip to content

Instantly share code, notes, and snippets.

Created July 16, 2013 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/6015732 to your computer and use it in GitHub Desktop.
Save anonymous/6015732 to your computer and use it in GitHub Desktop.
Simple wrapper for ssh to ssh into a server and cd to the current directory in the local machine.
function sshere {
CURRENT=$(pwd)
[[ "$CURRENT" =~ ^"$HOME"(/|$) ]] && CURRENT="~${CURRENT#$HOME}"
ssh -t ${1} "if [ -d $CURRENT ]; then cd $CURRENT; fi; exec \$SHELL"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment