9

I have tmux command key as C-a. C-Left/C-Right to jump between words (or whatever it is called) works just fine in urxvt alone, but under urxvt/tmux it'll print '5D' and '5C' for Left/Right respectively. How do I configure tmux so word skipping works (either with on X with urxvt or in a tty)?

2

4 Answers 4

15

Add this to your .Xdefaults

URxvt.keysym.Control-Up:     \033[1;5A
URxvt.keysym.Control-Down:   \033[1;5B
URxvt.keysym.Control-Left:   \033[1;5D
URxvt.keysym.Control-Right:  \033[1;5C

URxvt will now send the same escape sequences as XTerm.

This will make sure that word-jumping will even work when you are connected to a remote maching with its own .inputrc using SSH.

For making urxvt act more like xterm see http://www.netswarm.net/misc/urxvt-xtermcompat.txt

1
  • 3
    I added it to ~/.Xresources, ran cat ~/.Xresources | xrdb -merge and restarted the terminal. Works like a charm.
    – mauvm
    Jul 18, 2018 at 11:08
3

Excerpt from Ctrl-left and Ctrl-right in bash and Emacs:

Sometimes the small things make a big difference. I noticed that the control-left 
and control-right keys weren’t working in bash or Emacs on my FreeBSD box 
accessed over X11.app on OS X. Easily fixed.

.inputrc

    "\e[1;5C": forward-word     # Ctrl+right  => forward word
    "\e[1;5D": backward-word    # Ctrl+left   => backward word

.emacs

    (global-set-key "\M-[1;5C"    'forward-word)  ; Ctrl+right   => forward word
    (global-set-key "\M-[1;5D"    'backward-word) ; Ctrl+left    => backward word
  • I guess you'd need to do that in each programs and change their key bindings.
  • I don't know why tmux mangles the keystrokes going through though.
2

If you use zsh, add this to your ~/.zshrc

bindkey "5C" forward-word
bindkey "5D" backward-word

Got it from http://clock.co.uk/blog/zsh-ctrl-left-arrow-outputting-5d

1
  • This worked for me. Previous posts (.Xresouces, .xinputrc) did not.
    – oneself
    Oct 26, 2018 at 21:49
0

Answered here: https://superuser.com/a/395273/65499

C-b :set-window-option xterm-keys on

You must log in to answer this question.

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