jesseduffield / lazygit

simple terminal UI for git commands
MIT License
50.5k stars 1.78k forks source link

Support for image previewer #3776

Open wojciech-kulik opened 1 month ago

wojciech-kulik commented 1 month ago

Is your feature request related to a problem? Please describe. I'm always frustrated when I have to open GUI git client to see changed images.

Describe the solution you'd like It would be really nice to have image preview (before, after) within lazygit. Many terminals have great support for images (like kitty).

Describe alternatives you've considered To see image diff I must open git GUI client.

Additional context I use for example yazi and it works really well with images, similar solution should be introduced in lazygit.

stefanhaller commented 1 month ago

I don't think it's lazygit's job to support this. Lazygit doesn't render diffs, it only takes what it gets from git (possibly passed through a pager) and displays it as-is. So if you can get git to show the images when you type git diff in the command line, it should work in lazygit. If this doesn't work (and it doesn't for me, see below), then that would be a bug report for lazygit, not an enhancement request.

Here's some documentation that describes how to set up git so that it shows images in diffs (it looks like it's specific to iTerm2, maybe you need something slightly different for kitty).

I tried these instructions, and I could get it to work in the terminal; but only if I use the --no-pager option, or pipe it through cat:

image

However, it doesn't show in lazygit:

image

I haven't investigated yet why this is.

Another problem is that some pagers seem to have problems passing on the image data correctly; for example, it doesn't work with delta (see https://github.com/dandavison/delta/issues/1399), which is a major problem if you otherwise want to use delta in lazygit; I can't think of a workaround.

wojciech-kulik commented 1 month ago

@stefanhaller thank you for those tips, you are right, I was thinking about the right pane in lazygit more like some "previewer" window where I could configure how to present a diff based on a file type. However, I will try the solution you posted and see if it works 🍻 .

wojciech-kulik commented 1 month ago

I ended up with this solution for Kitty terminal: https://sw.kovidgoyal.net/kitty/kittens/diff but I'm not sure if it's possible to integrate it with lazygit