Skip to content

Instantly share code, notes, and snippets.

@tacahiroy
Created August 26, 2014 15:57
Show Gist options
  • Select an option

  • Save tacahiroy/b89f5d267c81bfccea19 to your computer and use it in GitHub Desktop.

Select an option

Save tacahiroy/b89f5d267c81bfccea19 to your computer and use it in GitHub Desktop.
tiny function that allows you to select and SSH to a host
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