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() {
|
_completion_get_hosts() {
|
||||||
print localhost
|
print localhost
|
||||||
if [[ -f ~/.ssh/config ]]; then
|
local line
|
||||||
awk "match(\$0, /^Host[[:blank:]]*/) { print substr(\$0, RLENGTH+1); }" ~/.ssh/config
|
< ~/.ssh/config while IFS= read -r line; do
|
||||||
fi
|
if [[ "$line" =~ '^Host[[:blank:]]+(.*)[[:blank:]]*' ]]; then
|
||||||
|
print -- "${match[1]}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
zstyle -e ':completion:*:hosts' hosts 'reply=("${(@f)$(_completion_get_hosts)}")'
|
zstyle -e ':completion:*:hosts' hosts 'reply=("${(@f)$(_completion_get_hosts)}")'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue