I searched and couldn't find a solution for this anywhere. I'm using PuTTY from Windows to connect to various servers where I run bash and screen. It seems bash works fine with ctrl-arrow keys to jump word-to-word on the command line but within screen it's not working. Not in screen, ctrl-left sends "^[OC and ctrl-right is "^[OD". Within screen I instead get "^[[C" and "^[[D", which appears to be the codes for just the left/right arrow keys. Is there any way to get screen to recognize ctrl-arrow keys when using PuTTY? (FYI, I don't remember having this problem when using gnu-terminal in linux instead of PuTTY).
UPDATE: It appears PuTTY is the problem as it is not sending the escape codes that are necessary for this to work. I'm giving up for now and using Cygwin+mintty.
As mentioned in here, u can put in ~/.inputrc:
It worked for me.
Edit:
Here's what worked for me:
~/.bashrc
setsTERM=xterm
(mine happens to beTERM=xterm-256colors
) overriding screen'sTERM=screen
tput smkx
at the Bash promptNow Ctrl-Arrow keys jump word-by-word
For informational purposes, if I do:
tput smkx | hexdump -c
I get
0000000 033 [ ? 1 h 033 =
and
tput rmkx | hexdump -c
gives me
0000000 033 [ ? 1 l 033 >
I think there's a way to rework this into something a little better, but it's what I've got so far and it seems to work.
Original answer:
From
info screen
:And VT100s don't have Ctrl-Arrow keycodes.
I'm somewhat surprised that you got Putty to send ctrl-arrowkeys correctly even without using screen, as that has never worked for me. My solution was to switch to using alt-arrowkeys (meta-arrowkeys), which I believe have the same forward-word / backward-word binding in bash by default, though I had to issue a couple extra commands for zsh to recognize them:
In case others find this old question like I did, a more recent solution:
http://stuff.mit.edu/afs/athena/project/bsd/src/tmux-1.3/FAQ
I'm using the Terminal > Keyboard > Function Keys > Xterm R6 That helps with htop (f4 search etc ) function keys working as expected.
What I've found out is that, instead of using CTRL + arrow, ALT + arrow jumps words instead.
I just experienced the opposite! For me, ctrl-left and ctrl-right did not have the desired effects in the command line, but they still worked in screen (and emacs). I think it has to do with the way your program inputs special characters. (I use MobaXterm now.)
My fix was simply adding these two lines to the
.inputrc
file:(The
;5C
and;5D
were what appeared in the command line when I used them before this fix.)You should look into the documentation of terminfo, ncurses, screen and putty if you want to debug/configure properly. Also bash shortcuts can be configured with inputrc. Look into the man pages of bash and search for inputrc.
Do you have the right character encoding in Putty ? If you connect to a server in UTF-8 and your putty is in standard charset, in vim, the arrow keys are written. If Putty is in UTF-8, you can move your cursor. Maybe it is the same in your case...
In your putty configuration under Terminal -> Features, there's a few "disable" checkboxes. You may want to try disabling application cursor keys or application keypad mode -- sometimes putty tries to be "too smart" and sends control characters that aren't compatible with the server.