__fish_print_hostnames: use awk to process ssh_config files

Uses awk rather than sed to account for multiple formatting options.

Closes #1260.
This commit is contained in:
David Adam 2014-09-29 14:08:09 +08:00
parent 6ece8523b1
commit f0d8d90ed1

View file

@ -18,11 +18,11 @@ function __fish_print_hostnames -d "Print a list of known hostnames"
# Print hosts from system wide ssh configuration file
if [ -e /etc/ssh/ssh_config ]
sgrep -Eoi '^ *host[^*]*$' /etc/ssh/ssh_config | cut -d ' ' -f 2 | tr ' ' '\n' | sgrep -v '[\*\?\!]'
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 ]
sgrep -Eoi '^ *host[^*]*$' ~/.ssh/config | cut -d ' ' -f 2 | tr ' ' '\n' | sgrep -v '[\*\?\!]'
awk -v FS="[ =]+" -v OFS='\n' 'tolower($0) ~ /^ *host[^*?!]*$/{ $1=""; print }' ~/.ssh/config
end
end