Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!
MIT License
2.97k stars 90 forks source link

[Q] Error when using fzf-tab's preview feature #444

Open NathanGrenier opened 1 month ago

NathanGrenier commented 1 month ago

Describe your question

Getting a weird error when using the preview feature in zsh. Not quite sure what to do to resolve it.

This is my .zshrc file:

# 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

# Set the directory we want to store zinit and plugins
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"

# Download Zinit, if it's not there yet
if [ ! -d "$ZINIT_HOME" ]; then
        mkdir -p "$(dirname $ZINIT_HOME)"
        git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi

# Source/Load zinit
source "${ZINIT_HOME}/zinit.zsh"

# Add Powerlevel10k
zinit ice depth=1; zinit light romkatv/powerlevel10k

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

# Install zsh plugins
zinit light Aloxaf/fzf-tab
zinit light zsh-users/zsh-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions

# Add in snippets
zinit snippet OMZP::git

# Load completions
autoload -U compinit && compinit

zinit cdreplay -q

# History
HISTSIZE=5000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTDUP=erase
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_ignore_dups
setopt hist_find_no_dups

# Completion styling
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'

# keybindings
bindkey '^f' autosuggest-accept
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward

# Aliases
alias cl='clear'
alias ls='ls --color'

# Shell integrations
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
eval "$(zoxide init zsh)"

# Navigate to home directory
cd ~

Screenshot of the Error

image

jathek commented 1 month ago

getting the same error. I'm wondering if the git-for-windows environment needs some adjustment from fzf-tab to work, because these dotfiles work fine on a linux box.

Note: I'm trying to use eza, but ls also fails with the same error.

.zshrc ```sh #!/bin/zsh # # .zshrc - Zsh file loaded on interactive shell sessions. # # 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 # set zsh options setopt extended_glob # clone antidote if necessary [[ -d ${ZDOTDIR:-~}/.antidote ]] || git clone https://github.com/mattmc3/antidote ${ZDOTDIR:-~}/.antidote # https://github.com/getantidote/antidote is stable # change antidote home directory - default on windows is %LocalAppData%/antidote export ANTIDOTE_HOME=${ZDOTDIR:-~}/.antidote_home # set the name of the static .zsh plugins file antidote will generate zsh_plugins=${ZDOTDIR:-~}/.antidote.zsh_plugins.zsh # ensure you have a $zsh_plugins_list file where you can add plugins zsh_plugins_list=${zsh_plugins:r}_list.zsh [[ -f ${zsh_plugins_list} ]] || touch ${zsh_plugins_list} # source zstyles you might use with antidote [[ -e ${ZDOTDIR:-~}/.antidote.zstyles.zsh ]] && source ${ZDOTDIR:-~}/.antidote.zstyles.zsh # lazy-load antidote fpath+=(${ZDOTDIR:-~}/.antidote) autoload -Uz $fpath[-1]/antidote # generate static file in a subshell when $zsh_plugins_list is updated alias al="antidote bundle <${zsh_plugins_list} >|$zsh_plugins" if [[ ! $zsh_plugins -nt ${zsh_plugins_list} ]]; then (al) fi # source your static plugins file source $zsh_plugins # autoload for prompts - see $zsh_plugins_list for explanation export ZSH_THEME='powerlevel10k' autoload -Uz promptinit && promptinit && prompt ${ZSH_THEME} # to customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh # source .profile [[ ! -f ~/.profile ]] || . ~/.profile ```
.antidote.zsh_plugins_list.zsh ```sh #!/bin/zsh # # .zsh_plugins.txt - antidote plugins file # # copied from https://github.com/getantidote/zdotdir/blob/1a34e6dd3d78862c82ba3babd19bd8c882c77d65/.zsh_plugins.txt ### Overview # # The `.zsh_plugins.txt` file is used by antidote to configure Zsh bundles. Bundles are # just a fancy way of referring to Zsh utilities, frameworks, prompts, or plugins. # `.zsh_plugins.txt` is used by antidote to generate a static `.zsh_plugins.zsh` file, # which can then be sourced in your `.zshrc`. You can use this file as a starting point # for your own config. Strip out instructional comments (ie: lines beginning with a '#') # and any plugins you don't need, then add what you like and make it yours! # # NOTE: Order matters in this file! Some bundles need to be last, and others are # prerequisites. Read the documentation for the plugins you use to ensure proper # configuration. # ### ### Completions # # You may want to add some additional completions to Zsh. Completions look in your fpath # for completion functions, which are functions named with a leading underscore # (eg: _git). You need to add all supplemental completions to your fpath prior to # running `compinit` to use completions functionality properly. You will want to find # a completion plugin that runs `compinit` for you, or you can run it yourself in # your .zshrc after antidote loads like this: # # autoload -Uz compinit && compinit # ### # zsh-users/zsh-completions is a popular plugin for adding supplemental completions. # We combine the `path:` and `kind:fpath` annotations here: jathek/zsh-completions path:src kind:fpath branch:custom # With antidote, using Zephyr's completion plugin is recommended. This plugin is meant # to be run near the TOP of your .zsh_plugins.txt file. mattmc3/zephyr path:plugins/completion # Most other compinit plugins should be near the END of .zsh_plugins.txt so that $fpath # has been fully populated. One such plugin is zsh-utils and its completion subplugin. # belak/zsh-utils path:completion ### Prompts # # You can make certain themes available to the built-in Zsh prompt command using the # `kind:fpath` annotation. A theme is not active for the prompt until this command is # run: # # autoload -Uz promptinit && promptinit # prompt ${prompt_name:-pure} # # There are two ways to load prompts. # - Add multiple prompt plugins to your `$fpath` with `kind:fpath` and then later in # your .zshrc run the Zsh built-in `prompt` to select the theme. # - Or, just load one prompt like a regular plugin. # ### romkatv/powerlevel10k kind:fpath ### Frameworks # # Frameworks are a collection of Zsh features, settings, and plugins meant to ease # Zsh configuration. Unfortunately, all that power can come with serious drawbacks. # Frameworks can often set more settings or aliases than you need, cluttering your Zsh # config and slowing things down. Use with caution! # # Frameworks are handled in antidote using the `path:location/of/plugin` annotation. # ### ### Framework: Oh-My-Zsh # # Oh-My-Zsh is a very popular Zsh framework. You might choose to use plugins from OMZ # in your own config. Depending on which plugins you use, you may also need to include # OMZ's entire "lib" directory. If you do this, be careful - "lib" configures a lot of # very broad settings. If you are familiar with what you are doing, you may choose to # only include parts of "lib". # # # use all of lib # ohmyzsh/ohmyzsh path:lib # # -OR-, only use only the specific files we care about # ohmyzsh/ohmyzsh path:lib/clipboard.zsh # #### ohmyzsh/ohmyzsh path:lib/key-bindings.zsh # 🌬️ A Zsh framework as nice as a cool summer breeze mattmc3/zephyr path:plugins/color mattmc3/zephyr path:plugins/directory # mattmc3/zephyr path:plugins/editor # use ohmyzsh for ctrl-del mattmc3/zephyr path:plugins/environment mattmc3/zephyr path:plugins/history mattmc3/zephyr path:plugins/utility mattmc3/zephyr path:plugins/zfunctions ### Regular Plugins # # Plugins are the simplest kind of bundles. You can point to a full git URL, or if you # assume GitHub.com, then you can use the user/repo shorthand. # ### # rummik/zsh-tailf # mattmc3/zman # zle tweak for emulating `...'==`../..' etc. yoogottamk/zsh-manydots-magic # 📎 ZSH plugin that reminds you to use existing aliases for commands you just typed MichaelAquilina/zsh-you-should-use path:you-should-use.plugin.zsh # Good-lookin' diffs. Actually… nah… The best-lookin' diffs. 🎉 so-fancy/diff-so-fancy # Replace zsh's default completion selection menu with fzf! Aloxaf/fzf-tab # A ZSH plugin to set the terminal tab title according to current directory or running process. It's based (forked) from Oh-My-ZSH one. trystan2k/zsh-tab-title ### widget wrapping plugins # zsh-users/zsh-syntax-highlighting # use zdharma-continuum/fast-syntax-highlighting instead zdharma-continuum/fast-syntax-highlighting ### Final Plugins # # Remember plugin order matters! Put plugins that need run last at the bottom of your # .zsh_plugins.txt file. # ### # These popular core plugins should be loaded at the end zsh-users/zsh-autosuggestions zsh-users/zsh-history-substring-search ```
.antidote.zstyles.zsh ```sh #!/bin/zsh # # .zstyles - Set zstyle settings for plugins that need them. # # # Antidote # # friendly plugin directories - no 'https-COLON--SLASH--SLASH-github.com-SLASH-' zstyle ':antidote:bundle' use-friendly-names 'yes' # change default zsh_plugins.txt name zstyle ':antidote:bundle' file ${zsh_plugins_list} # Aloxaf/fzf-tab # disable sort when completing `git checkout` zstyle ':completion:*:git-checkout:*' sort false # set descriptions format to enable group support # NOTE: don't use escape sequences here, fzf-tab will ignore them zstyle ':completion:*:descriptions' format '-- %d --' # set list-colors to enable filename colorizing zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} # force zsh not to show completion menu, which allows fzf-tab to capture the unambiguous prefix zstyle ':completion:*' menu no # preview directory's content with eza when completing cd zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' # switch group using `<` and `>` zstyle ':fzf-tab:*' switch-group '<' '>' ```
Aloxaf commented 3 weeks ago

what's the value of $ZSH_NAME on windows?

jathek commented 3 weeks ago

just "zsh"

image