Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request regarding Ctrl-Q #1229

Open
fansari opened this issue Mar 17, 2022 · 16 comments
Open

Feature request regarding Ctrl-Q #1229

fansari opened this issue Mar 17, 2022 · 16 comments
Labels
action Issues related to actions duplicate This issue or pull request already exists

Comments

@fansari
Copy link

fansari commented Mar 17, 2022

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.

@a-kenji a-kenji added duplicate This issue or pull request already exists action Issues related to actions labels Mar 17, 2022
@a-kenji
Copy link
Contributor

a-kenji commented Mar 17, 2022

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

@fansari
Copy link
Author

fansari commented Mar 17, 2022

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.

@imsnif
Copy link
Member

imsnif commented Mar 17, 2022

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)

@tranzystorekk
Copy link
Contributor

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

@a-kenji
Copy link
Contributor

a-kenji commented Mar 22, 2022

Yes, since that isn't an action.

@imsnif
Copy link
Member

imsnif commented Mar 22, 2022

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.

@raphCode
Copy link
Contributor

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
Copy link
Contributor

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

@dwvisser
Copy link

dwvisser commented Nov 30, 2022

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.

@azzamsa
Copy link

azzamsa commented Dec 15, 2022

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"
}

@raphCode
Copy link
Contributor

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

@fansari
Copy link
Author

fansari commented May 19, 2023

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; }
  }

@robrecord
Copy link

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.

@bestia-dev
Copy link

bestia-dev commented Aug 1, 2023

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.

@msmafra
Copy link

msmafra commented Jan 11, 2024

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

@cristiand391
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action Issues related to actions duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests