aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_print_hostnames.fish
diff options
context:
space:
mode:
authorGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2013-09-19 23:18:35 +0800
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2013-09-19 23:24:36 +0800
commitc2dcfc917635593f34b590dd3b53ae7866e9dfa3 (patch)
tree018b1615bb9aeccd550f5b726ef2bda6a91a0d87 /share/functions/__fish_print_hostnames.fish
parentdf300e042b12cc045669f39a9b2c6f7296f0d2f9 (diff)
__fish_print_hostnames: do a better job of searching SSH files
Diffstat (limited to 'share/functions/__fish_print_hostnames.fish')
-rw-r--r--share/functions/__fish_print_hostnames.fish6
1 files changed, 4 insertions, 2 deletions
diff --git a/share/functions/__fish_print_hostnames.fish b/share/functions/__fish_print_hostnames.fish
index 423f9952..2c737a69 100644
--- a/share/functions/__fish_print_hostnames.fish
+++ b/share/functions/__fish_print_hostnames.fish
@@ -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