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)?

stelonix
  • 271
  • 3
  • 6
  • What program are you typing the C-Left and C-Right into? If it is a shell, which shell it is? Does its configuration have any bindings (i.e. `bind` in *bash* and `bindkey` in *zsh*)? What TERM are you using inside your *tmux* panes? – Chris Johnsen Mar 12 '13 at 06:22
  • Possible duplicate of [How can I make ctrl+left/right keys work right in tmux?](http://superuser.com/questions/360832/how-can-i-make-ctrlleft-right-keys-work-right-in-tmux) – UpAndAdam Feb 24 '16 at 22:01

4 Answers4

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

Dominik Heidler
  • 151
  • 1
  • 7
  • 3
    I added it to `~/.Xresources`, ran `cat ~/.Xresources | xrdb -merge` and restarted the terminal. Works like a charm. – mauvm Jul 18 '18 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.
slm
  • 9,959
  • 10
  • 49
  • 57
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

Tarrasch
  • 208
  • 1
  • 10
0

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

C-b :set-window-option xterm-keys on
isomorphismes
  • 1,864
  • 2
  • 20
  • 31