broot icon indicating copy to clipboard operation
broot copied to clipboard

remove temp files used by kitty

Open Canop opened this issue 1 year ago • 4 comments

In order to display images with the Kitty protocol, broot creates temp files at the optimal dimensions and gives them to the terminal.

A problem with this approach is that those images may take a lot of space, especially if you're on linux and never reboot, as the /tmp folder is usually emptied on reboot.

With this commit:

  • broot, on quitting, deletes all the temp files it created
  • broot has a maximum number of temp files (defined with the kept_kitty_temp_files config entry) and removes the least recently used one when the max is reached

Canop avatar Oct 20 '24 16:10 Canop

Just FYI the kitty protocol allows you to tell the terminal emulator to delete the file after it has read the image data.

kovidgoyal avatar Oct 20 '24 16:10 kovidgoyal

@kovidgoyal Yes but we don't want to: when scrolling over images you're very likely to need the same image again very soon. And building an image is sometimes expensive, eg when dealing ~~with SVG or~~ huge images.

Canop avatar Oct 20 '24 16:10 Canop

BTW @kovidgoyal I'm impressed. What's your trick to be notified when kitty is mentionned ? I'd need this superpower too...

Canop avatar Oct 20 '24 16:10 Canop

github lets you search across their entire database for keywords. I have a custom script that does that for me at an interval and notifies of new issues/prs/discussions for topics I am interested in. But if all you are interested in is one or two topics you can just use the github web frontends search function manually, it works reasonably well and just takes a minute or two a day.

kovidgoyal avatar Oct 20 '24 16:10 kovidgoyal