18 lines
354 B
Plaintext
18 lines
354 B
Plaintext
|
_get_ssh_hosts(){
|
||
|
cat $HOME/.ssh/config | grep '^Host ' | sed "s/Host //"
|
||
|
}
|
||
|
|
||
|
_ssh(){
|
||
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||
|
# prev=${COMP_WORDS[COMP_CWORD-1]}
|
||
|
if [ $COMP_CWORD -eq 1 ]; then
|
||
|
COMPREPLY=( $( compgen -W "$(_get_ssh_hosts)" $cur ) )
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
complete -F _ssh -o default ssh
|
||
|
complete -F _ssh -o default scp
|
||
|
|
||
|
|
||
|
# vim:filetype=sh
|