lincheney / fzf-tab-completion

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

zstyle completion doesn't open preview #107

Closed dyegoe closed 1 month ago

dyegoe commented 2 months ago

Hi

I added to my dotfiles, the following: zstyle ':completion::*:ls::*' fzf-completion-opts --preview='eval head {1} --tmux bottom'

If I hit ls <tab> the fzf opens, but without preview. Any idea what am I missing?

# ##### FZF #####
export FZF_DEFAULT_COMMAND='fd -H -E .git -E .cache'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND='fd -t d -H -E .git -E .cache'
export FZF_DEFAULT_OPTS='
  --color=fg:-1,fg+:#d0d0d0,bg:-1,bg+:#262626
  --color=hl:#5f87af,hl+:#5fd7ff,info:#afaf87,marker:#87ff00
  --color=prompt:#d7005f,spinner:#af5fff,pointer:#af5fff,header:#87afaf
  --color=border:#262626,label:#aeaeae,query:#d9d9d9
  --border="bold" --border-label=""
  --preview-window="border-rounded,down:70%:wrap"
  --bind="ctrl-/:change-preview-window(hidden|)"
  --prompt="> " --marker=">" --pointer="◆" --separator="─" --scrollbar="│"
  --layout="reverse" --height="50%" --info="right" --multi'
export FZF_PREVIEW_COMMAND='[[ $(file --mime {}) =~ directory ]] && eza --tree --level 1 --color=always --icons {} || ([[ $(file --mime {}) =~ binary ]] && echo {} is binary file || bat -n --color=always -r :500 {})'
export FZF_CTRL_T_OPTS="--preview='$FZF_PREVIEW_COMMAND'"
export FZF_ALT_C_OPTS="--preview='eza --tree --level 1 --color=always --icons {} | head -n 200'"

By the way, the previous works for:

cd **<tab>
cd <ctrl + t>
cd <alt + c>

I am running it on Linux

lincheney commented 1 month ago

If I have only in my zshrc the following

zstyle ':completion::*:ls::*' fzf-completion-opts --preview='eval head {1}' --tmux bottom

autoload -Uz compinit
compinit -C
source ~/.fzf/shell/completion.zsh
source ~/repos/fzf-tab-completion/fzf-zsh-completion.zsh

Then the preview shows up fine for me. It also works even if I put in the other FZF env vars that you listed. So I am not sure what is happening for you.

dyegoe commented 1 month ago

Thank you for getting back to me. Since you ensured that it is working from your side, I dug a bit more and just realised that I had an alias ls = eza --icons --git. So, instead of zstyle ':completion::*:ls::*' fzf-completion-opts --preview='eval head {1}' --tmux bottom it must be zstyle ':completion::*:eza::*' fzf-completion-opts --preview='eval head {1}' --tmux bottom