summaryrefslogtreecommitdiff
path: root/.bash_completion.d/ssh.bash
blob: fbbbd0c68a59d74b57c44a407ee04387d3507e6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!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