gitui icon indicating copy to clipboard operation
gitui copied to clipboard

Support opening inside of Helix

Open nik-rev opened this issue 10 months ago • 6 comments

Yazi (A file explorer written in Rust) recently added support for using yazi right inside of Helix via :insert-output

You can use Lazygit right inside of Helix as well. This is described in the Helix wiki (https://github.com/helix-editor/helix/wiki/Recipes#git-integration)

I wanted to try out gitui. So I gave it a shot and wow its about 3x faster (benchmark: undoing changes for 1,200 files). So I want to use it now. I tried using it in Helix's :insert-output but it does not work.

:insert-output uses Helix's shell_impl_async to turn the output of the passed cmd: &str and display it in the editor

You can check Yazi's PR on how they implemented it and it may be implemented here in a similar way.

:insert-output gitui would ideally allow you to use gitui right within Helix, but at the moment it just freezes the screen.

nik-rev avatar Mar 11 '25 00:03 nik-rev

Sounds reasonable, I am not using helix but I am open to take a PR for it

extrawurst avatar Mar 11 '25 08:03 extrawurst

@nik-rev: For a quick workaround, redirect gitui's output to /dev/tty:

[keys.normal]
C-g = [
    ":write-all",
    ":new",
    ":insert-output gitui >/dev/tty",
    ":buffer-close!",
    ":redraw",
    ":reload-all"
]

Also, make sure helix's cwd is a git repository. Otherwise gitui prints a message and immediately terminates; the message is then overwritten by helix.

For a more permanent solution, gitui could consider rendering to /dev/tty or support it as a command line option.

naseschwarz avatar Mar 15 '25 01:03 naseschwarz

It doesn't seem to work on macOS. Any idea as to why that might be? I have tried with different terminals (WezTerm, iTerm2 and ghostty). One thing that I notice was that my user didn't have execution permission on /dev/tty. I change it, and started to something happen, but it immediately terminated (I was in a CWD with a git repository).

nffdiogosilva avatar Mar 27 '25 00:03 nffdiogosilva

The workaround proposed by @naseschwarz works flawlessly for me (Linux + WezTerm). Unfortunately I do not have a macOS, so cannot help debug it.

On another note. @extrawurst, do we really need to add a command line for rendering the output to /dev/tty and also handle the case for Windows users? I believe that the key-bindings option in Helix is quite elegant and would stay out of gitui's responsability. I'm open to work on a PR. Just checking if it is really needed.

martihomssoler avatar May 08 '25 06:05 martihomssoler

Maybe I'm misunderstanding you here, @martihomssoler, and I guess we're already be on the same page. :)

Helix, as far as I can tell, does not support passing a shell command's output through to its own output. Output in helix's shell_impl_async will only be processed once the process has ended. Thus my workaround: Just bypass helix for rendering.

A patch actually fixing this issue should be addressed at helix. My suggestion for natively supporting /dev/tty is indeed mostly a convenience feature and "being nice" to helix users. It actually, probably, doesn't really belong into gitui.

naseschwarz avatar May 08 '25 11:05 naseschwarz

So, there isn't any PR for using gitui on Yazi For helix?

billy42757 avatar Oct 05 '25 21:10 billy42757