Skip to content

Instantly share code, notes, and snippets.

@yamamoto-febc
Created July 10, 2017 08:12
Show Gist options
  • Save yamamoto-febc/8b86ccd547262f098de0d1855ab65d7e to your computer and use it in GitHub Desktop.
Save yamamoto-febc/8b86ccd547262f098de0d1855ab65d7e to your computer and use it in GitHub Desktop.
peco + usacloud for ssh
##
# select ssh host from usacloud server list
#
function peco-select-usacloud-ssh-host(){
local res
row=$(usacloud server list | grep -v "^\+--" | peco)
res=$(echo $row | awk '{print $2;}')
if zle; then
if [ -n "$res" ]; then
BUFFER="usacloud server ssh $res"
zle accept-line
fi
CURSOR=$#BUFFER
zle clear-screen
else
if [ -n "$res" ]; then
BUFFER="usacloud server ssh $res"
print -z "${BUFFER}"
fi
fi
}
zle -N peco-select-usacloud-ssh-host
bindkey '^g' peco-select-usacloud-ssh-host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment