#!bash if [[ -r ~/.ssh/config ]]; then function ssh_complete { word=${COMP_WORDS[COMP_CWORD]} allwords="$(awk '/^Host / { print $NF }' ~/.ssh/config)" COMPREPLY=( $(compgen -W "$allwords" $word) ) } complete -F ssh_complete ssh fi if [[ -r ~/.ssh/home ]]; then function home_ssh_complete { word=${COMP_WORDS[COMP_CWORD]} allwords="$(awk '/^Host / { print $NF }' ~/.ssh/home)" COMPREPLY=( $(compgen -W "$allwords" $word) ) } complete -F home_ssh_complete hssh fi