Created
January 14, 2015 04:20
-
-
Save c9n/e19b199847a8e6ecfcf7 to your computer and use it in GitHub Desktop.
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
_complete_hosts () { | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
host_list=`{ | |
for c in ~/.ssh/config | |
do [ -r $c ] && sed -n -e 's/^[[:space:]]*Host[[:space:]]//p' $c | |
done | |
} | tr ' ' '\n'|grep -v '*'` | |
COMPREPLY=( $(compgen -W "${host_list}" -- $cur)) | |
return 0 | |
} | |
complete -F _complete_hosts ssh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment