aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_print_hostnames.fish
diff options
context:
space:
mode:
Diffstat (limited to 'share/functions/__fish_print_hostnames.fish')
-rw-r--r--share/functions/__fish_print_hostnames.fish11
1 files changed, 7 insertions, 4 deletions
diff --git a/share/functions/__fish_print_hostnames.fish b/share/functions/__fish_print_hostnames.fish
index 2c737a69..eadb21f5 100644
--- a/share/functions/__fish_print_hostnames.fish
+++ b/share/functions/__fish_print_hostnames.fish
@@ -14,12 +14,15 @@ function __fish_print_hostnames -d "Print a list of known hostnames"
# Print hosts with known ssh keys
# Does not match hostnames with @directives specified
- sgrep -Eoh '^[^#@|, ]*' ~/.ssh/known_hosts{,2} ^/dev/null
+ sgrep -Eoh '^[^#@|, ]*' ~/.ssh/known_hosts{,2} ^/dev/null | sed -E 's/^\[([^]]+)\]:([0-9]+)$/\1/'
+
+ # Print hosts from system wide ssh configuration file
+ if [ -e /etc/ssh/ssh_config ]
+ awk -v FS="[ =]+" -v OFS='\n' 'tolower($0) ~ /^ *host[^*?!]*$/{ $1=""; print }' /etc/ssh/ssh_config
+ end
# Print hosts from ssh configuration file
if [ -e ~/.ssh/config ]
- # Ignore lines containing wildcards
- sgrep -Eoi '^ *host[^*]*$' ~/.ssh/config | cut -d '=' -f 2 | tr ' ' '\n'
+ awk -v FS="[ =]+" -v OFS='\n' 'tolower($0) ~ /^ *host[^*?!]*$/{ $1=""; print }' ~/.ssh/config
end
end
-