Created
July 10, 2017 08:12
-
-
Save yamamoto-febc/8b86ccd547262f098de0d1855ab65d7e 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 | |
| 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