summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2019-08-06 15:37:08 +0200
committerFlorian Pritz <bluewind@xinu.at>2019-10-08 15:59:12 +0200
commit0134c738cc55668ade593b3420e582be88ce3462 (patch)
treed4bacf8c46e7791d94e7fcd49ec0e5c215f36df5
parenta62d29f385a223c0a251e4e4a90496076f90174d (diff)
downloaddotfiles-0134c738cc55668ade593b3420e582be88ce3462.tar.gz
dotfiles-0134c738cc55668ade593b3420e582be88ce3462.tar.xz
zshrc: Add fzf hosts completion
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--.zshrc19
1 files changed, 19 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
index ac97d9b..ab08cc3 100644
--- a/.zshrc
+++ b/.zshrc
@@ -265,11 +265,29 @@ fzf-file-widget() {
return $ret
}
+__fhost() {
+ printf "%s\n" $hosts | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do
+ echo -n "${(q)item} "
+ done
+ local ret=$?
+ echo
+ return $ret
+}
+
+fzf-hosts-widget() {
+ LBUFFER="${LBUFFER}$(__fhost)"
+ local ret=$?
+ zle reset-prompt
+ return $ret
+}
+
if type fzf &>/dev/null; then
zle -N fzf-history-widget
bindkey '^R' fzf-history-widget
zle -N fzf-file-widget
bindkey '^T' fzf-file-widget
+ zle -N fzf-hosts-widget
+ bindkey '^H' fzf-hosts-widget
fi
# }}}
@@ -709,6 +727,7 @@ hosts=(
$_ssh_config_hosts[@]
localhost
)
+hosts=(${(u)hosts[@]})
zstyle ':completion:*:hosts' hosts $hosts
# automagic url quoter