Closed tapyu closed 1 year ago
I am aware that we are already using --preview
option. But my idea is to have both the text and the cover image in the preview...
Ok, that is my try (it is not working properly, actualy)
function fpp()
{
# open PDF using fuzzy finder with preview
rg --type 'pdf' --files | fast-p | fzf --read0 --reverse -e -d $'\t' \
--preview-window down:80% --preview '
pdftoppm -f 1 -l 1 -singlefile -jpeg -tiffcompression jpeg -- {1} | viu -
'
}
I've used viu project, which is quite straightforward. I supposed that the work behavior may be over {1}
(I suppose that it return the filename), is that right?
The result is
PS: I'm not worried about opening the file at the moment.
When changing viu
by catimg
, I can get the image properly. The downside s that catimg
returns a image in a much lower quality. Why is it happening?
If you use viu -b
it works. . .
Image preview inside fzf preview window or tmux seems very hard to work with (search engines point to many bugs and hackish solutions) and requires specific terminal (kitty, ...).
Why not use an actual pdf viewer? The following launches evince for ~/a.pdf, and fzf links its top result at all times to ~/a.pdf. Evince will update automatically its content with the pdf of the top result in fzf.
evince ~/a.pdf & \
rg --type 'pdf' --files | fast-p | fzf --read0 --reverse -e -d $'\t' --preview 'echo {1}; ln -f {1} ~/a.pdf'
@bellecp
Why not use an actual pdf viewer?
Because my idea was precisely see the pdf cover image on terminal before launching it. But I got it. It is not so trivial due to internal issues... That's sad :(
I tried the following with evince/sway and it is pretty smooth. It should be more robust than previewing with images inside the terminal. Bind foot bash ~/.local/bin/q.sh
to a keyboard shortcut with
# ~/.local/bin/q.sh
evince ~/a.pdf &
PID="$!"
swaymsg "no_focus [pid="$PID"]"
FILE="$(rg --type 'pdf' --files | fast-p | ~/.fzf/bin/fzf --read0 --reverse -e -d $'\t' \
--bind 'focus:execute(ln -f {1} ~/a.pdf)' \
| cut -z -f 1 -d $'\t' | tr -d '\n')"
kill "$PID"
if [ -z "$FILE" ]; then
exit
else
nohup xdg-open "$FILE" &
sleep 0.05
exit
fi
or create a bash function with parts of the above code (removing exit) to launch from terminal.
I will close this for now but others can comment to improve the quality of the preview.
It would be great to have a image preview integrated with
fast-p
and fuzzy file. The idea it to see the cover image of the selected pdf file. Anyone has idea how to implement that?