mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
ish's current hostname completion uses ~/.ssh/known_hosts as one of its sources of information, but ~/.ssh/config may also be useful. Gather all of the 'Host' declarations from ~/.ssh/config and filter out the ones with wildcards. Signed-off-by: James Vega <jamessan@debian.org>
darcs-hash:20090202210242-ac50b-cf50070ee33ab6113e32a4d997d464ac4b1faf24.gz
This commit is contained in:
parent
9d7224d756
commit
05341b055b
3 changed files with 5 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue