0

CTRL+_ is used to do UNDO in console; is it possible to map that another key combination like CMD + Z?

1
  • Have you seen this discussion? Maybe it can be of help. – maulinglawns Oct 4 '16 at 17:48
1

Yes, but that depends on your shell. In bash, you have to use bind:

$ bind '\C-t':undo

This will bind Ctrl-t to undo. Note that you cannot bind Ctrl-z in most terminal emulators. Refer to help bind for more information.

If you want the current list of all key bindings, use bind -P | grep -v "not found".


In zsh, you have to use bindkey:

$ bindkey '\C-t' undo

Keep in mind that you probably want to remove the old bindings for whatever key you'll choose. For example, \C-t is bound to transpose-chars.

In case you're wondering where all those combinations come from: Emacs. See man 1 bash, section "Readline Command Names" for more information.

1
  • You actually can bind Ctrl-z in zsh. Also, this does not depend on the terminal emulator, but on the shell. While a terminal emulator might prevent Ctrl-z from being used, I think it unlikely that any terminal emulator actually does do this, as this is shortcut is generally used to send SIGSTOP to the running process. – Adaephon Oct 10 '16 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.