Anshul Goyal
Anshul Goyal

Reputation: 25

unable to use fzf-preview in zshell

I am trying to add plugins like in this script which I found on dreams of autonomy

here is the link to that .zshrc below is my attempt without using zinit

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

if [[ -f "/opt/homebrew/bin/brew" ]] then
  eval "$(/opt/homebrew/bin/brew shellenv)"
fi

source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /opt/homebrew/share/powerlevel10k/powerlevel10k.zsh-theme

autoload -U compinit; compinit

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

source ~/Documents/fzf-tab/fzf-tab.plugin.zsh



bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward

HISTFILE=$HOME/.zhistory
SAVEHIST=5000
HISTSIZE=5000
HISTDUP=erase

setopt appendhistory
setopt sharehistory
setopt hist_ignore_dups
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_find_no_dups


zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${eza}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'eza $realpath'


alias cd='z'
alias ls="eza --icons=always"
alias c='clear'

eval "$(fzf --zsh)"
eval "$(zoxide init zsh)"
eval $(thefuck --alias)
eval $(thefuck --alias fk)

Everything in my script is working well except the fzf-preview part, I am unable to figure out what I am doing wrong.

Edit: This solves the problem.

zstyle ':fzf-tab:complete:*' fzf-preview 'eza $realpath'

but I don't understand why

zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza $realpath' 
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'eza $realpath'

isn't working

Upvotes: 1

Views: 686

Answers (1)

Ravi Pinto
Ravi Pinto

Reputation: 15

I am assuming you have replaced cd with zoxide via the following command

    zoxide init --cmd=cd zsh

If so, the OS does not know about 'z' command. So, that cancels this

    zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'eza $realpath'

What worked for me is the second one, after changing 'eza' to 'ls'. In my setup, 'ls' is already aliased to 'eza'. So, what is working for me is the following

    zstyle ":fzf-tab:complete:cd:*" fzf-preview 'ls --color $realpath'

I have this alias defined for 'ls'

    alias ls="eza --icons=always --git"

Upvotes: 0

Related Questions