Solaris – SSH Ctrl Arrow Keys Not Working

puttysolarisssh

I connect to SunOS 5.11 11.3 machine via ssh using putty.

In terminal ctrl + arrow keys are not moving cursor to the previous/next words.

There is simple bash terminal on the Solaris machine.

Do you know how to fix this issue?

In the past I had this issue and already applied the solution (set terminal type string in putty to "linux"), but now I also want arrow keys working.

Best Answer

PuTTY doesn't do that. It's a feature of xterm, and is one of many features of xterm not provided by PuTTY: sending different escape sequences depending on whether the Control and/or Shift key is pressed at the same time.

xterm-style modifiers for cursor keys are supported in ncurses by a extended terminal description (not part of conventional X/Open or SVr4 terminfo). However, PuTTY does not implement xterm-style modifiers in this case. For a long time, it used the Shift key to switch between normal and application modes for the cursor keys, and recently changed the modifier to the Control key:

commit 41e1a586fb956539a74bc446984a100e0138cd77                                 
Author: Simon Tatham                                          
Date:   Sat Dec 8 08:25:32 2018 +0000 

     - swapping the arrow keys between normal (ESC [ A) and application         
       (ESC O A) is now done by pressing Ctrl with them, and _not_ by           
       pressing Shift. That was how it was always supposed to work, and         
       how it's worked on GTK all along, but on Windows it's been done by       
       Shift as well since 2010, due to a bug at the call site of               
       format_arrow_key() introduced when I originally wrote that function.

but that did not change the escape sequence used. In the change comment, ESC [ A refers to the normal-mode up-arrow, and ESC O A to the application-mode up-arrow.

ncurses provides an accurate terminal description for PuTTY, but in this case the terminal description is irrelevant because bash uses hard-coded escapes in .inputrc (zsh does a little better, but also is lacking in this area--see the xterm manual). Even supposing that bash used the terminal description, the information is not available to bash because the terminal description's names cannot be read using a termcap application (such as bash). As mentioned, zsh is a little better, but it does not read extensions.

Using

infocmp -x xterm

you might notice kLFT5, kRIT5, kUP5, kDN5 (which are the names given to the control-modified cursor keys--all extensions), but you will not find those in the putty terminal description because PuTTY doesn't do that.

Related Question