slavistan / lf-gadgets

A collection of useful and nifty use cases and configurations for lf.
GNU General Public License v3.0
132 stars 16 forks source link

Bat preview not working #12

Closed zakissimo closed 2 years ago

zakissimo commented 2 years ago

I'm trying to get the bat preview instead of cat for any text file. I changed the previewer file but the output is still the same.

# lf-ueberzug-previewer
-  *) cat "$file" ;;
+  *) bat "$file" ;;

image image

zakissimo commented 2 years ago

Nevermind, I used "-f" to force colors and it works. (a bit slow but looks nice)

*) bat -f "$file" ;;

image

Is there a way to make it fast ?

slavistan commented 2 years ago

@zakissimo I use bat for previews as well, and while it's noticeably slower to generate the preview than cat, it's still fast enough for me. You could check whether bat is the bottleneck in your setup or if there is some other configuration issue by running a few bat commands manually in the terminal in order to get a feel for the startup latency of bat vs cat. That latency is, of course, the best you'll get out of your lf previews.

If you're working on an older or slower machine take note that bat is orders of magnitude larger and more complex than cat (ls -la /usr/bin/bat /usr/bin/cat). This complexity comes at a price, which may be noticeable on lower-end machines.

zakissimo commented 2 years ago

Yes it's definitely my machine @slavistan . Thanks for your input and sorry for the inconvenience .