I am using a laptop and Putty on a Windows system.

When I connect to my Debian Squeeze server in Bash environment, I can use the "Pos1/Home" or "End" (at the numlock part of the keyboard) to navigate through the commandline I am just writing.

However, when I create a "subshell" using screen, I cannot use Pos1/Home or End anymore. Pressing Num-Lock does not help.


The problem can probably be fixed by setting the $TERM variable in screen. Try adding term screen-256color to ~/.screenrc.

If this does not work, try adding termcapinfo xterm ks@:ke@' to~/.screenrc` as well. This might break some other keys so you should test it thoroughly.

  • Setting that environment variable in ~/.screenrc or launching screen -T screen-256color does not help. Ctrl+V does not work in Putty. But it does work if I perform the keystroke at the actual machine (I am testing on a VM now). Home/End does always work in screen when I am at the virtual machine, but does not work when I do the same in Putty+Screen. – Daniel Marschall Jun 3 '14 at 8:43
  • Ctrl+V at the virtual machine showed the keys ^[[1~ and ^[[4~ . Adding these 2 keys in ~/.inputrc does not help. Probably the keycodes passed through PuTTy are different. (However, Putty+Bash does work, but Putty+Screen does not work!) Is it correct entering "^[[1~": begin-of-line in ~/.inputrc or do I need to replace ^ with \e or [[ with [? (I tried various) – Daniel Marschall Jun 3 '14 at 8:44
  • Oh, I somehow completely ignored the part of the question that mentioned you are doing this through putty. I found a working solution, at least one that works on my computer using Putty to SSH to an Arch Linux machine. I will update my answer. – arnefm Jun 3 '14 at 9:14
  • Thanks. But alas, it does not work - the screen just blinks when I press the Home key. I have changed ~/.screenrc to: term linux . But that does not work. When I execute screen and (inside screen) echo $TERM I will get screen-256color . If I then enter TERM=linux inside screen, it will work. How can I tell screen to do that automatically at each start? – Daniel Marschall Jun 3 '14 at 9:46
  • I have just found the solution. I changed the terminal type in PuTTy from xterm to linux. This affects both, bash and screen. Thank you all the same for taking time to help me. :-) Your hint with the TERM setting was important to find the problem. – Daniel Marschall Jun 3 '14 at 10:03

I have found the reason why it didn't work.

In the PuTTy configuration I had to change the session settings as follows:

Connection -> Data -> Terminal details -> Terminal-type string

The value was: xterm I changed it to linux

Now I can use the Home+End keys in Bash and in Screen as well.

echo $TERM will show linux outside screen and screen.linux inside screen.

UPDATE 23 Oct 2018

I have found a much easier solution!

Just start screen with this command:

TERM=linux screen

or put this line in your ~/.bashrc :

alias screen='TERM=linux screen'

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.