diff --git a/share/completions/ssh.fish b/share/completions/ssh.fish index 4af4c2e5e..5cbaacfff 100644 --- a/share/completions/ssh.fish +++ b/share/completions/ssh.fish @@ -4,11 +4,6 @@ __fish_complete_ssh ssh -complete -x -c ssh -d Alias -a " - -(__fish_print_ssh_aliases) -" - complete -x -c ssh -d Hostname -a " (__fish_print_hostnames) diff --git a/share/functions/__fish_print_hostnames.fish b/share/functions/__fish_print_hostnames.fish index 69e41e0da..52efc7313 100644 --- a/share/functions/__fish_print_hostnames.fish +++ b/share/functions/__fish_print_hostnames.fish @@ -12,5 +12,10 @@ function __fish_print_hostnames -d "Print a list of known hostnames" # Print hosts with known ssh keys cat ~/.ssh/known_hosts{,2} ^/dev/null|cut -d ' ' -f 1| cut -d , -f 1 + + # Print hosts from ssh configuration file + if [ -e ~/.ssh/config ] + grep '^ *Host' ~/.ssh/config | grep -v '[*?]' | cut -d ' ' -f 2 + end end diff --git a/share/functions/__fish_print_ssh_aliases.fish b/share/functions/__fish_print_ssh_aliases.fish deleted file mode 100644 index 719c991ec..000000000 --- a/share/functions/__fish_print_ssh_aliases.fish +++ /dev/null @@ -1,7 +0,0 @@ - -function __fish_print_ssh_aliases -d "Print a list of known ssh aliases" - # Print ssh aliases - if test -f ~/.ssh/config - awk '/^[[:space:]]*Host\>/ {print $2}' ~/.ssh/config - end -end