lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Allow ctrl-z to suspend lazygit

Open ricardoseriani opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. Cannot suspend lazygit using ctrl-z

Describe the solution you'd like Provide a way to disable the ctrl-z keybinding to Redo, and allow the command to send lazygit to background.

Describe alternatives you've considered I cannot think of any alternative way to do this, but if there is some, please let me known.

Additional context The majority of software that run on Linux terminal allow the use of ctrl-z to suspend the current software, allowing to run fg or bg commands to continue the software on foreground or background.

But, currently, the ctrl-z keybinding is tied to Redo. Even if I try to remap the Redo command using the .config/lazygit/config.yml like the following, I cannot run ctrl-z to suspend lazygit


keybinding:
  universal:
    redo: <c-g>

ricardoseriani avatar Sep 11 '24 19:09 ricardoseriani

interesting.

@ricardoseriani for now, I use dislocate -escape '^Z' lazygit for this purpose [^1][^2]

[^1]: dislocate(1) is a old expect script, it just works [^2]: ^Z is a "ctrl-z character", ascii 0x1A, which can usually be obtained by typing ctrl-v ctrl-z

terminalzeiro avatar Sep 15 '24 02:09 terminalzeiro

It is a curious mapping by default, ctrl-z serves as the suspend signal by default in any tty I can recall.

m-fonseca avatar Feb 12 '25 16:02 m-fonseca

for those who are interested in this topic, I wrote a 15-line expect script which "emulates" suspend (not really) function for lazygit

https://gist.github.com/terminalzeiro/3b985f568fa604b1d1fbcfb9f7620374

terminalzeiro avatar Mar 25 '25 10:03 terminalzeiro

here is a working build with suspend behavior working. <c-z> is bound to redo so I was unsure if the plan was to rebind redo to another combo or bind suspend to something other than <c-z>. Currently I bound it to <c-a> to test it out.

cowboy8625 avatar Jul 19 '25 12:07 cowboy8625

@cowboy8625 Nice.

I think redo is not a frequently needed command (undo is), so I'd be up for changing its keybinding, maybe to shift-Z.

I'm not very familiar with signal handling concepts, so I barely understand what your code does, but I noticed a problem when testing: when you press ctrl-a to suspend lazygit, and then type bg, I get

[1]  + continued  ./lazygit
[1]  + suspended (tty output)  ./lazygit

After that, fg hangs, and the only way to get out of this is to kill lazygit from a different terminal.

This needs to be fixed somehow before we can use this.

stefanhaller avatar Jul 19 '25 12:07 stefanhaller

Ah thanks for bring this to my attention. I will look into it. Also thanks for the quick response.

cowboy8625 avatar Jul 19 '25 14:07 cowboy8625