dotfiles/bash_completion.d/ssh

18 lines
354 B
Plaintext
Raw Normal View History

_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