mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[zsh] parse ~/.ssh/config with a zsh script instead of awk as well
This commit is contained in:
parent
412015d374
commit
789d9caefd
1 changed files with 6 additions and 3 deletions
|
@ -40,9 +40,12 @@ zstyle ':completion:*:processes' force-list always
|
|||
|
||||
_completion_get_hosts() {
|
||||
print localhost
|
||||
if [[ -f ~/.ssh/config ]]; then
|
||||
awk "match(\$0, /^Host[[:blank:]]*/) { print substr(\$0, RLENGTH+1); }" ~/.ssh/config
|
||||
fi
|
||||
local line
|
||||
< ~/.ssh/config while IFS= read -r line; do
|
||||
if [[ "$line" =~ '^Host[[:blank:]]+(.*)[[:blank:]]*' ]]; then
|
||||
print -- "${match[1]}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
zstyle -e ':completion:*:hosts' hosts 'reply=("${(@f)$(_completion_get_hosts)}")'
|
||||
|
||||
|
|
Loading…
Reference in a new issue