zellij icon indicating copy to clipboard operation
zellij copied to clipboard

Feature request regarding Ctrl-Q

Open fansari opened this issue 2 years ago • 16 comments

Since I have now accidently used "Ctrl-Q" many times I would like to ask whether there can be done something preventing this.

Maybe a more complicated action or some question whether you really want to do it.

Closing everything is nothing I normally do intend to do so it would be good to change this.

fansari avatar Mar 17 '22 09:03 fansari

Hey! I am working on including this feature. And some preliminary work has been done to support it.

Related issues: #933, #467

Here is a preview of the prototype:

image

a-kenji avatar Mar 17 '22 09:03 a-kenji

Great. I found this comment in #467: "Also on other "terminating" operations, like "tab close" and "pane close".

I can confirm this. It is not a normal workflow that you want to close a tab. Normally such thing only happens by accident. So it would be good to have also this protection for tabs and panes.

fansari avatar Mar 17 '22 09:03 fansari

Great. I found this comment in #467: "Also on other "terminating" operations, like "tab close" and "pane close".

I can confirm this. It is not a normal workflow that you want to close a tab. Normally such thing only happens by accident. So it would be good to have also this protection for tabs and panes.

I do sometimes want to close many panes quickly. Maybe we add a confirmation for closing a tab/pane, and also add a "force close" shortcut (eg. ctrl-p + x => close with confirmation, ctrl-p + X => close without confirmation)

imsnif avatar Mar 17 '22 10:03 imsnif

I usually close zellij by closing the shell with Ctrl + D, I'm guessing that will remain without confirmation?

tranzystorekk avatar Mar 22 '22 13:03 tranzystorekk

Yes, since that isn't an action.

a-kenji avatar Mar 22 '22 13:03 a-kenji

I usually close zellij by closing the shell with Ctrl + D, I'm guessing that will remain without confirmation?

There's also not a lot we can do about this, tbh. We only intercept keys to the shell if they correspond to one of our UI actions. This is an internal shell thing - for one shell it can be ctrl + d, for another it can be something else.

imsnif avatar Mar 22 '22 13:03 imsnif

Maybe we add a confirmation for closing a tab/pane, and also add a "force close" shortcut

I feel like using a "double key" could solve the problem: The first x leading to a confirmation question with x as 'yes' and any other key as 'no'.

If you really want to close something, it is easy to get the double keypress into muscle memory, while inadvertently pressing the close combination twice seems unlikely.

This should also play nice with key remapping.

raphCode avatar Mar 22 '22 20:03 raphCode

Since it wasn't mentioned already, it is totally possible to remap the offending actions to keys that are more difficult to hit by accident or remove the mapping altogether: https://zellij.dev/documentation/keybindings.html

raphCode avatar Nov 30 '22 10:11 raphCode

Since it wasn't mentioned already, it is totally possible to remap the offending actions to keys that are more difficult to hit by accident …

I am a micro user (where CTRL-Q is the way to quit the editor) and re-mapping zellij's quit action to Alt-Q has effectively solved this annoyance for me.

dwvisser avatar Nov 30 '22 12:11 dwvisser

Since it wasn't mentioned already, it is totally possible to remap the offending actions to keys that are more difficult to hit by accident or remove the mapping altogether:

Thanks for this idea @raphCode. I have solved my long standing issue that always bugs me.

keybinds {
   unbind "Ctrl q"
}

azzamsa avatar Dec 15 '22 22:12 azzamsa

Mhh, so should we close this? Or add a hint to the documentation?

raphCode avatar Dec 16 '22 12:12 raphCode

I have tried this now and it works for me. But this is not exactly what I want.

How can I create a key binding with a combination of two keys?

I have tried this and it does not work. zellij closes as soon as I enter Ctrl-b.

keybinds {
  unbind "Ctrl q"
  normal {
    bind "Ctrl b Ctrl q" { Quit; }
  }
}

This also does not work as combination:

keybinds {
  unbind "Ctrl q"
  normal {
    bind "Ctrl b" "Ctrl q" { Quit; }
  }
}

And this gives an error message when starting zellij:

keybinds {
  unbind "Ctrl q"
  normal {
    bind "Ctrl bq" { Quit; }
  }

fansari avatar May 19 '23 09:05 fansari

I've worked around it by moving the keybnding for Quit from the shared_except "locked" section to the session section. Now I have to do Ctrl-o Ctrl-q to quit.

robrecord avatar Jun 23 '23 13:06 robrecord

I am new to Zellij and I already hit the ctrl-Q problem. It is too easy to press ctrl-Q, because many programs use that. And BOOM - all is lost in a second. In the zellij:status-bar all other commands need 2 key-strokes to do something. for example "SESSION":

Untitled

When using ctrl-Q for Quit, it should be "normal" to show other possibilities like: "quit", "detach", "lock" or "cancel".

Untitled_quit

I mean "by default", without messing with the key bindings.

bestia-dev avatar Aug 01 '23 13:08 bestia-dev

Hello there Based on @bestia-dev and @robrecord comments, what is working for me is putting the Quit option inside the session{} function/area/session after enabling the clear-defaults=true for keybinds{} and unbinding the Ctrl q combination. I'm not sure if the correct way or if there is any redundancy, but works. I'm using Zellij 0.39.2, since it started in 2022 I imagine it wasn't possible.

Changed

keybinds {

To

keybinds clear-defaults=true {
    unbind "Ctrl q";

Added

bind "q" { Quit; }

To

session {

So to quit pressing Ctrl + O and then q is needed: Captura de tela de 2024-01-11 10-32-10

msmafra avatar Jan 11 '24 13:01 msmafra

fyi: I created a plugin to add a confirmation prompt before killing your session: https://github.com/cristiand391/zj-quit

it's intended to replace the Quit keybind action.

cristiand391 avatar Jun 05 '24 12:06 cristiand391