dotfiles/bash_completion.d/ssh
Dan Buch a8cd5a2fe9 Attempting to carve out a sensible chunk of stuff for a dotfiles repo.
Sure hope I didn't miss any super secret crap :-P
2012-02-26 14:38:01 -05:00

18 lines
354 B
Bash

_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