The gnome-terminal ANSI escape sequence for “CTRL + arrow/s”

escape-charactersgnome-terminalkeyboard shortcutstmux

I am trying to configure my bash ~/.inputrc to these settings
(Note: , mean the left and right arrow keys)

  • Ctrl + – should jump back a word
  • Ctrl + – should jump forward a word

Currently I have this in my ~/.inputrc and it doesn't work. Ctrl + arrow produces nothing.

"\eC-5C":forward-word
"\eC-5D":backward-word

I'm sure my escape sequence is wrong.
What are the correct escape sequences for the Ctrl + arrow combinations?

  • terminal: tmux inside gnome-terminal

Best Answer

Gnome-terminal (more properly VTE) imitates some version of xterm's escape sequences. How closely it does this, depends on the version of VTE.

The relevant xterm documentation is in the PC-Style Function Keys section of XTerm Control Sequences.

What you are looking for is a string like \e[1;5D (for control left-arrow), where the 5 denotes the control modifier.

In ncurses, you can see these strings using infocmp -x, as the values for kUP5, kDN5, kLFT5 and kRIT5. For example:

    kDN5=\E[1;5B,
    kLFT5=\E[1;5D,
    kRIT5=\E[1;5C,        
    kUP5=\E[1;5A,
Related Question