Closed LoveCatc closed 1 month ago
I have the same issue with you.
I reduce my config file step by step, and find the problem in line
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
the command eza doesn't exsit on my computer.
After I run sudo apt install eza
, the problem fixed.
Hi NightWatcher314, thank you for the sincere help! Unfortunately, this does not solve my problem. But you provide a very nice point, and I should look through the config more carefully. Anyway thank you again!
I have the same problem. It's related to the FZF_DEFAULT_OPTS
variable, specifically the "--preview" argument.
I know that's a fzf thing, but the issue only happens when I use fzf through this plugin. If I simply run fzf, the preview window works fine.
Also, if I use the fzf plugin (for example, writing nano **
and pressing Tab
) it also works fine.
Hi, thank you guys for helping me a lot! Today I carefully looked through the history issues and found #77 is really similar to my case. With the help of GPT-4, I managed to find the working config for me. Besides the basic FZF_DEFAULT_COMMAND
and FZF_DEFAULT_OPTS
variables, we have to also use zstyle
to make things work properly. I add the following part to make it work:
export _PREVIEW_="$HOME/dotfiles/zsh/preview.zsh"
local extract="
local in=\${\${\"\$(<{f})\"%\$'\0'*}#*\$'\0'}
local -A ctxt
for entry in \${(@ps:\2:)CTXT}; do
local key=\${entry%%=*}
local value=\${entry#*=}
ctxt[\$key]=\$value
done
local realpath=\${ctxt[IPREFIX]}\${ctxt[hpre]}\$in
realpath=\${(Qe)~realpath}
"
zstyle ':fzf-tab:complete:*:*' fzf-flags --preview=$extract';$_PREVIEW_ $realpath'
And the preview.zsh
is very simple:
#!/usr/bin/env zsh
# Check if the file exists
if [[ -e "$1" ]]; then
# If the file is a regular text file, display its content
if [[ $(file --mime-type -b "$1") == text/* ]]; then
# Use highlight for syntax highlighting or fallback to cat
(highlight -O ansi "$1" || cat "$1") 2> /dev/null | head -500
else
# If not a text file, display the file type
file "$1"
fi
else
# If the file does not exist, print the filename
echo "$1"
fi
Hope this would help!
Describe the bug
The preview window shows "fork/exec /usr/bin/zsh: invalid argument" and it even happens when opening logs (
C-x .
).I can make sure:
compinit
To Reproduce
Steps to reproduce the behavior:
ls
Expected behavior
The preview window should give correct information instead of an error.
Screenshots
Environment:
Minimal zshrc
.zshrc
fzf.zsh
Log
If applicable, use
C-x .
to trigger completion and provide the log.If there are only three lines in your log, please make sure your fzf-tab is loaded with the correct order (see the checklist above).
no logs are shown.