From c2dcfc917635593f34b590dd3b53ae7866e9dfa3 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 19 Sep 2013 23:18:35 +0800 Subject: [PATCH] __fish_print_hostnames: do a better job of searching SSH files --- share/functions/__fish_print_hostnames.fish | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/functions/__fish_print_hostnames.fish b/share/functions/__fish_print_hostnames.fish index 423f9952d..2c737a69a 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