4

For years I have been using a different prefix key for nested instances on tmux. I use \ on my own server, but a for any other servers I connect to and start a nested tmux session.

I have found this trick which uses Shift+Arrow Keys to switch between windows and nested instances, which is much better.

However, it does not work when I am using PuTTY (using Windows) but it does when I use KiTTY. I cannot figure out why it is not working with PuTTY.

Ctrl+v, Arrow Keys returns the same codes in the terminal when using either programs.


EDIT:

Just after starting a bounty I have realized that Ctrl+v, SHIFT+Arrow Keys does actually come up with different codes.

PuTTY:

SHIFT+Left Arrow = ^[OD

SHIFT+Right Arrow = ^[OC

SHIFT+Up Arrow = ^[OA

SHIFT+Down Arrow = ^[OB

KiTTY:

SHIFT+Right Arrow = ^[[1;2D

SHIFT+Right Arrow = ^[[1;2C

SHIFT+Up Arrow = ^[[1;2A

SHIFT+Down Arrow = ^[[1;2B

So how do I change PuTTY so that it sends the same codes with SHIFT+Arrow Keys?

  • Just after I started the bounty I realised that shift+arrow keys does come up with different escape codes for the programs, so I will accept an answer on how to change the codes in putty to the ones that work, as I cannot cancel the bounty. – paradroid Jun 30 '17 at 13:47
  • Have you tried to change PuTTY configuration: Terminal, Keyboard section? – Kamil Maciorowski Jun 30 '17 at 13:58
  • @KamilMaciorowski I am looking at the options there but cannot see anything relevant. I have updated my question. If you can figure it out I'll accept your answer. – paradroid Jun 30 '17 at 14:00
3
+250

The answer is you can't, since this is a bug in PuTTY. This was discussed some time ago at stack - https://stackoverflow.com/questions/6202310/putty-shift-arrows

I had the similar problem with tmux and PuTTY, and I switched to KiTTY.

1

I also cannot manage to find any method for remapping keys in PuTTY, so I suggest using a AutoHotkey script.

An example script that maps ShiftRight to the keys Esc[1;2D, but only for windows whose title contains putty.exe, is:

#IfWinActive, putty.exe
+Right::SendInput, {esc}[1;2D
#IfWinActive

Place the script in a file with the suffix .ahk and double-click to test. If it works, you could copy it to the Startup scripts folder so it starts when you logon.

1

Since Kitty is a fork of Putty they have very similar settings. Mostly likely your Terminal > Keyboard settings are different between Kitty and Putty. Making the Putty settings match the Kitty settings (as close as possible) should resolve the problem for you. Particularly The Function keys and keypad. Also, check the Terminal > Features section as well.

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.