mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 05:41:16 -03:00
__fish_print_hostnames: do a better job of searching SSH files
This commit is contained in:
@@ -13,11 +13,13 @@ function __fish_print_hostnames -d "Print a list of known hostnames"
|
||||
end
|
||||
|
||||
# Print hosts with known ssh keys
|
||||
cat ~/.ssh/known_hosts{,2} ^/dev/null | grep -v '^|' | cut -d ' ' -f 1| cut -d , -f 1
|
||||
# Does not match hostnames with @directives specified
|
||||
sgrep -Eoh '^[^#@|, ]*' ~/.ssh/known_hosts{,2} ^/dev/null
|
||||
|
||||
# Print hosts from ssh configuration file
|
||||
if [ -e ~/.ssh/config ]
|
||||
sgrep -i '^ *host' ~/.ssh/config | grep -v '[*?]' | cut -d ' ' -f 2
|
||||
# Ignore lines containing wildcards
|
||||
sgrep -Eoi '^ *host[^*]*$' ~/.ssh/config | cut -d '=' -f 2 | tr ' ' '\n'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user