2

I've configured tmux to skip words on Ctrl+right / left :

set-window-option -g xterm-keys on

It works just fine, but as I do SSH, it doesn't work and prints ;5D or ;5C..

The same issue occurred when I used screen, is there some specific configuration for tmux/screen on SSH ?

5

It's not tmux nor screen that "skips words"; the text input is provided by your shell. You must therefore find out what key sequence Ctrl+arrows generate, and teach your shell that it means "skip a word". Otherwise, it will stop interpreting mid-sequence because it's not recognized.

If you're using bash, it takes some of the key definitions from ncurses/terminfo, and others from the "inputrc" file. So first make sure you have the ncurses terminal definitions installed ("ncurses-term" or similar). And if you have a custom ~/.inputrc, tell it to import the system-wide one, using:

$include /etc/inputrc

If that doesn't help, add a custom mapping to your ~/.inputrc file (on the server, of course):

  1. In bash, press CtrlV (the "verbatim input" key), followed by Ctrl. You'll see the "Ctrl+right" escape sequence inserted as plain text:

    ^[[1;5C
    

    The ^[ means an "ESC" character; the rest are plain text. So this is ESC [ 1 ; 5 C.

  2. In man bash, find the inputrc ("readline") command for skipping a word. (It's forward-word.)

  3. In ~/.inputrc, add both the key sequence and the command. (The "ESC" is written as \e.)

    "\e[1;5C": forward-word
    
  4. Repeat the same for Ctrl.

  5. Close ssh, then connect again and see if it works.

Note that most distributions already have these particular mappings in /etc/inputrc.

  • I can't edit anything on the server itself. Adding "\e[1;5C": forward-word to ` ~/.inputrc` (on my system) doesn't help. – SagiLow Feb 26 '15 at 13:04
  • 1
    @SagiLow: Of course it doesn't help – the server can't see what files the client has... There's really nothing the client could do to fix this, anyway. – grawity Feb 27 '15 at 13:35
  • my colleagues who uses Ubuntu 12 manage to this this just fine, even when connecting to the same remote system. I don't think it cannot be done – SagiLow Mar 1 '15 at 8:11
  • bash uses none of the extended key-definitions from the terminal database (such as the "ctrl+arrow" in the question). For that, it relies exclusively on the user's .inputrc file. – Thomas Dickey Apr 28 '15 at 0:17

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.