lincheney / fzf-tab-completion

Tab completion using fzf
GNU General Public License v3.0
623 stars 40 forks source link

Not working with ssh #97

Closed fmiqbal closed 5 months ago

fmiqbal commented 5 months ago

I seems can't get it working with SSH, i do modify the known hosts command to get subfolder, ssh ** works

if ! declare -F __fzf_list_hosts > /dev/null; then
  __fzf_list_hosts() {
    command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/*/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | command awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') \
      <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts 2> /dev/null | command tr ',' '\n' | command tr -d '[' | command awk '{ print $1 " " $1 }') \
      <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0' | command sed 's/#.*//') |
      command awk '{for (i = 2; i <= NF; i++) print $i}' | command sort -u
  }
fi

eval "$(fzf --bash)"

export FZF_COMPLETION_AUTO_COMMON_PREFIX=true
export FZF_COMPLETION_AUTO_COMMON_PREFIX_PART=true
source ~/packages/fzf-tab-completion/bash/fzf-bash-completion.sh
bind -x '"\t": fzf_bash_completion'

but using ssh <TAB> just looks like when its cd <TAB>

asciicast

any other command i think its working, git, kubectl

on branch master, with fzf 0.48.1

lincheney commented 5 months ago

If you're trying to customise the completion functions provided by fzf (different to fzf-tab-completion), then you still need to use their mechanism and use the ** trigger. This is the fzf behaviour, this repo doesn't change it.

If you want to without having to type the ** trigger, you can try something like this: https://github.com/junegunn/fzf/wiki/Examples-(completion)#bash-custom-trigger-less-completion