I have installed sunlei/zsh-ssh, however it conflicts with Z4H.
After some digging I realized that the issue comes from the plugin changing the bindkey to use it's own instead of z4h-fzf-complete.
zle -N fzf_complete_ssh
bindkey '^I' fzf_complete_ssh
Inside the function it also has a fallback option for ${fzf_ssh_default_completion:-expand-or-complete}.
fzf_complete_ssh() {
local tokens cmd result selected_host
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
tokens=(${(z)LBUFFER})
cmd=${tokens[1]}
if [[ "$LBUFFER" =~ "^ *ssh$" ]]; then
zle ${fzf_ssh_default_completion:-expand-or-complete}
elif [[ "$cmd" == "ssh" ]]; then
result=$(_ssh_host_list ${tokens[2, -1]})
fuzzy_input="${LBUFFER#"$tokens[1] "}"
if [ -z "$result" ]; then
zle ${fzf_ssh_default_completion:-expand-or-complete}
return
fi
if [ $(echo $result | wc -l) -eq 1 ]; then
_set_lbuffer $result false
zle reset-prompt
# zle redisplay
return
fi
result=$(_fzf_list_generator $result | fzf \
--height 40% \
--ansi \
--border \
--cycle \
--info=inline \
--header-lines=2 \
--reverse \
--prompt='SSH Remote > ' \
--query=$fuzzy_input \
--no-separator \
--bind 'shift-tab:up,tab:down,bspace:backward-delete-char/eof' \
--preview 'ssh -T -G $(cut -f 1 -d " " <<< {}) | grep -i -E "^User |^HostName |^Port |^ControlMaster |^ForwardAgent |^LocalForward |^IdentityFile |^RemoteForward |^ProxyCommand |^ProxyJump " | column -t' \
--preview-window=right:40%
)
if [ -n "$result" ]; then
_set_lbuffer $result true
zle accept-line
fi
zle reset-prompt
# zle redisplay
# Fall back to default completion
else
zle ${fzf_ssh_default_completion:-expand-or-complete}
fi
}
I placed the source after z4h init and added a variable fzf_ssh_default_completion="z4h-fzf-complete" before sourcing zsh-ssh.zsh so it would call z4h-fzf-complete whenever the command isn't ssh.
However, it still breaks the zstyle options, despite being loaded correctly, which I have no idea how to fix.
❯ zstyle -L ':z4h:fzf-complete'
zstyle :z4h:fzf-complete fzf-bindings tab:repeat
zstyle :z4h:fzf-complete recurse-dirs no
zstyle works even after sourcing zsh-ssh.zsh if I use z4h-fzf-complete but no matter what I try, it's ignored with fzf_complete_ssh
I have a low understanding of how zstyle works.
If anyone could point me to the right direction on how to troubleshoot or fix the issue, I would really appreciate it.
I have installed sunlei/zsh-ssh, however it conflicts with Z4H.
After some digging I realized that the issue comes from the plugin changing the bindkey to use it's own instead of
z4h-fzf-complete.Inside the function it also has a fallback option for
${fzf_ssh_default_completion:-expand-or-complete}.I placed the source after
z4h initand added a variablefzf_ssh_default_completion="z4h-fzf-complete"before sourcingzsh-ssh.zshso it would callz4h-fzf-completewhenever the command isn'tssh.However, it still breaks the zstyle options, despite being loaded correctly, which I have no idea how to fix.
zstyle works even after sourcing
zsh-ssh.zshif I usez4h-fzf-completebut no matter what I try, it's ignored withfzf_complete_sshI have a low understanding of how zstyle works.
If anyone could point me to the right direction on how to troubleshoot or fix the issue, I would really appreciate it.