mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[zsh] fix hosts completion when ssh config doesn't exist
This commit is contained in:
parent
16b40e1982
commit
a3c85fa826
1 changed files with 8 additions and 1 deletions
|
@ -38,4 +38,11 @@ zstyle ':completion:*:processes' command "ps xo pid,user,cmd"
|
||||||
zstyle ':completion:*:processes-names' command "ps xho comm="
|
zstyle ':completion:*:processes-names' command "ps xho comm="
|
||||||
zstyle ':completion:*:processes' force-list always
|
zstyle ':completion:*:processes' force-list always
|
||||||
|
|
||||||
zstyle -e ':completion:*:hosts' hosts 'reply=("${(@f)$(awk "match(\$0, /^Host[[:blank:]]*/) { print substr(\$0, RLENGTH+1); }" ~/.ssh/config)}")'
|
_completion_get_hosts() {
|
||||||
|
print localhost
|
||||||
|
if [[ -f ~/.ssh/config ]]; then
|
||||||
|
awk "match(\$0, /^Host[[:blank:]]*/) { print substr(\$0, RLENGTH+1); }" ~/.ssh/config
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
zstyle -e ':completion:*:hosts' hosts 'reply=("${(@f)$(_completion_get_hosts)}")
|
||||||
|
'
|
||||||
|
|
Loading…
Reference in a new issue