Last active
July 10, 2017 07:59
-
-
Save hitsumabushi/5ef85d9ba8afdb667aaf2e9f13dcb0d1 to your computer and use it in GitHub Desktop.
peco + usacloud for ssh
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
## | |
# select ssh host from usacloud server list | |
# | |
function peco-select-usacloud-ssh-host(){ | |
local res | |
# IPでアクセス | |
res=$(echo $row | cut -d'|' -f 6 | sed -e 's/ *\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\)\/.*/\1/') | |
# hostname が名前解決できる場合 | |
# row=$(usacloud server list | grep -v "^\+--" | peco) | |
res=$(echo $row | awk '{print $4;}') | |
if zle; then | |
if [ -n "$res" ]; then | |
BUFFER="ssh $res" | |
zle accept-line | |
fi | |
CURSOR=$#BUFFER | |
zle clear-screen | |
else | |
if [ -n "$res" ]; then | |
BUFFER="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