This question is a spin-off of Rebinding "clear prompt" in mutt

I use vim keybindings a lot and like using esc to abort commands. I've now moved to mutt but it is not possible to bind esc to 'abort' in Mutt (see above). Instead, I would like to map esc to esc+Ctrl-g. My hope is to get the esc key to send both key sequences. That way esc is a kind of universal abort key for vim and mutt.

I've mapped Ctrl-g to 'no operation' in .vimrc with nmap <C-g> <nop> so there's no conflict in Vim.

Preferably I would like this mapping to be set in .Xdefaults or .Xresources so that the strange esc to esc+Ctrl-g mapping only applies to urxvt (my terminal em) and programs run inside it. By making this apply more globally in Xinput or Xmodmap I will have to stay on the lookout for what this mapping does to other (possibly non-cli) programs. That said, any suggestions are welcome :)

1 Answer 1


You can use the keysym resource. This requires that rxvt has been compiled with the --enable-frills option. Put this line in your ~/.Xresources:

URxvt.keysym.Escape: \033\007

Run xrdb -merge ~/.Xresources to reload the resource files. The settings only apply to programs started after running xrdb -merge.

If you want, you can have different settings depending on a parameter passed to rxvt. Choose a name like urxvt-mutt; it must begin with a lowercase letter and should begin with urxvt so that it doesn't conflict with names used by other applications. Add this line to ~/.Xresources:

urxvt-mutt.keysym.Escape: \033\007

Then when you run urxvt -name urxvt-mutt you'll get this binding (overriding any binding set with URxvt.keysym.Escape), but when you run urxvt with no -name option you'll only get the URxvt bindings.

  • 1
    I was aware of keysym but how did you find the code \033\007 ?
    – bkanuka
    Commented Jul 17, 2013 at 15:08
  • This was extremely helpful. I tried for hours to do this before asking on se. I wish I had more rep to give you as a reward. Thank you very much.
    – bkanuka
    Commented Jul 17, 2013 at 15:25
  • If i understood correctly, terminals use octal values and we are talking about escape sequences. Escape has the decimal value of 27, which in octal is 033. Therefore <kbd>Ctrl-G</kbd>, which has the decimal value 7, has the octal value 007 (BEL). Hence \033\007. And if I'm correct, you need to place a command: before that sequence.
    – WGRM
    Commented Jan 12, 2020 at 23:44
  • @WGRM Your understanding of the syntax is correct, but not your understanding of whose syntax it is. The Some.thing: stuff syntax and backslash-octal in strings are X resources. The dotted names before the colon (Some.thing) are a property of the application. Commented Jan 14, 2020 at 3:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .