leo-arch/clifm

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:

  1. Create a directory and two files text.txt and text2.txt.
  2. Fill them with text and try to preview them with "file"+tab-completion.
  3. The file isn't displayed in the preview and remains in a loading loop.

Expected behavior
Print a preview of the file

Screenshots
2024-06-30-234159_hyprshot
2024-06-30-235800_hyprshot
2024-06-30-234110_hyprshot

Desktop:

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:

  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.

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 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:

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.
  1. works

2024-07-01-094003_hyprshot

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 (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?

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:

  1. Fzf uses $SHELL -c to run the command passed via --preview, in our case clifm --preview (see fzf(1) for more info). So, the complete and actually executed command is $SHELL -c 'clifm --preview {}', which expanded is clifm -c "clifm --preview 'file.txt'".
  2. Now, the -c switch tells clifm to create and start from a new config file specified as argument, so that clifm --preview 'file.txt' is created as a new config file in the current directory.
  3. 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.