Skip to content

Instantly share code, notes, and snippets.

@6d61726b760a
Created May 28, 2017 23:32
Show Gist options
  • Save 6d61726b760a/85e46c305f3bb5c8606274f03a40e66c to your computer and use it in GitHub Desktop.
Save 6d61726b760a/85e46c305f3bb5c8606274f03a40e66c to your computer and use it in GitHub Desktop.
start an ssh session in a new tmux window
#!/bin/bash
if [ $# -eq 0 ] || [ $# -gt 1 ];
then
echo "usage: r [username]@hostname"
exit
fi
input="$*"
case "$*" in
*\@*)
user="${input%%\@*}"
host="${input##*@}"
tmux new-window -n "${host}" ssh "${user}@${host}"
;;
*)
host="${input}"
tmux new-window -n ${host} ssh "${host}"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment