Created
August 26, 2014 15:57
-
-
Save tacahiroy/b89f5d267c81bfccea19 to your computer and use it in GitHub Desktop.
tiny function that allows you to select and SSH to a host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function peco-ssh() { | |
| local _host=$(grep -o '^\S\+' ~/.ssh/known_hosts | tr -d '[]' | tr ',' '\n' | sort | peco) | |
| if [ ${TMUX} ]; then | |
| eval $(printf "tmux neww -n %s 'ssh %s'" ${_host} ${_host}) | |
| else | |
| eval $(printf 'ssh %s' ${_host}) | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment