Fzf preview Bug
Closed this issue · 5 comments
Describe the bug
Fzf preview doesn't work. The loading animation doesn't finish. And additional file get created/stored (3. screenshot):
"clifm --preview 'file.txt'"
"clifm --preview 'file2.txt'"
To Reproduce
Steps to reproduce the behavior:
- Create a directory and two files text.txt and text2.txt.
- Fill them with text and try to preview them with "file"+tab-completion.
- The file isn't displayed in the preview and remains in a loading loop.
Expected behavior
Print a preview of the file
Desktop:
- OS: NixOS 24.11 Unstable
- Terminal: foot and alacritty
- CliFM version 1.19 and 1.19.2, commit: 3c1128b
- Installation source: git, modified https://github.com/r-ryantm/nixpkgs/blob/2a18d15ebbf4c3359f67af1dee5e4e2f73e2d546/pkgs/applications/file-managers/clifm/default.nix
Hi @theRoboxx.
clifm --preview {}
is the command passed to fzf
to generate the preview of the file under the cursor in fzf
. It's weird the whole command (with the file name expanded) is created as a file. Perform these operations outside clifm:
- Run
clifm --preview file.txt
andclifm --preview file2.txt
. It should generate the file previews in place. - Launch
fzf
as follows:fzf --preview "clifm --preview {}"
in the directory containing these two files. It should launchfzf
generating previews for both files.
If everything works as expected, run clifm with a fresh config dir (and thereby fresh config files): clifm -D ~/.config/clifm.test
. If we have some config issue, this should solve it.
Btw, what's your fzf
version?
EDIT: Please paste here you FzfTabOptions
line (run cs edit
, go to the bottom of the file and locate FzfTabOptions). Maybe some wrong parameter is being passed to fzf
. Also, have you set any of FZF_DEFAULT_COMMAND, FZF_DEFAULT_OPTS, or FZF_DEFAULT_OPTS_FILE environment variables?
I think I got it. I've reproduced the issue (or something similar) by setting the SHELL environment variable to clifm
, before running clifm:
export SHELL=clifm
clifm
So, try unsetting SHELL (or setting it to something like /bin/bash
):
unset SHELL
clifm
Hi @theRoboxx.
clifm --preview {}
is the command passed tofzf
to generate the preview of the file under the cursor infzf
. It's weird the whole command (with the file name expanded) is created as a file. Perform these operations outside clifm:1. Run `clifm --preview file.txt` and `clifm --preview file2.txt`. It should generate the file previews in place. 2. Launch `fzf` as follows: `fzf --preview "clifm --preview {}"` in the directory containing these two files. It should launch `fzf` generating previews for both files.
- works
If everything works as expected, run clifm with a fresh config dir (and thereby fresh config files):
clifm -D ~/.config/clifm.test
. If we have some config issue, this should solve it.Btw, what's your
fzf
version?
<0> $ fzf --version
0.53.0 (0.53.0)
EDIT: Please paste here you
FzfTabOptions
line (runcs edit
, go to the bottom of the file and locate FzfTabOptions). Maybe some wrong parameter is being passed tofzf
. Also, have you set any of FZF_DEFAULT_COMMAND, FZF_DEFAULT_OPTS, or FZF_DEFAULT_OPTS_FILE environment variables?
FzfTabOptions="--color='dark,prompt:#8be9fd,fg+:-1,pointer:#6272a4,hl:#bd93f9,hl+:#bd93f9,gutter:-1,marker:#50fa7b:bold,query:#f8f8f2,info:#f8f8f2:dim,border:8' --marker='*' --bind tab:accept,right:accept,left:abort,alt-p:toggle-preview,change:top,alt-up:preview-page-up,alt-down:preview-page-down --inline-info --layout=reverse-list --preview-window=wrap,border-left"
<0> $ echo $FZF_DEFAULT_COMMAND
(empty)
<0> $ echo $FZF_DEFAULT_OPTS
(empty)
<0> $ echo $FZF_DEFAULT_OPTS_FILE
(empty)
I think I got it. I've reproduced the issue (or something similar) by setting the SHELL environment variable to
clifm
, before running clifm:export SHELL=clifm clifm
So, try unsetting SHELL (or setting it to something like
/bin/bash
):unset SHELL clifm
Yes, this fixed it. I set it to /bin/zsh and now it works 👍 .
Is this a bug or is clifm not intendet to be set to $SHELL?
Is this a bug or is clifm not intendet to be set to $SHELL?
No, it isn't a bug. Clifm is not intended to be a shell, but a file manager.
In this specific case this is what happened:
- Fzf uses
$SHELL -c
to run the command passed via--preview
, in our caseclifm --preview
(see fzf(1) for more info). So, the complete and actually executed command is$SHELL -c 'clifm --preview {}'
, which expanded isclifm -c "clifm --preview 'file.txt'"
. - Now, the
-c
switch tells clifm to create and start from a new config file specified as argument, so thatclifm --preview 'file.txt'
is created as a new config file in the current directory. - After creating the specified config file, clifm starts as usual, which is what we see in your two first screenshots: clifm running inside the fzf preview window.