# PuTTY Bash - Home & End keys



## notfed (Jul 27, 2011)

Hi,

Say I'm using Bash and have typed in a very long line.  Now, I'd like to go back to the beginning of the line without needing to hold LEFT.  I can usually just hit HOME and END to go to the beginning and end of a line.  But in PuTTY, this doesn't work; pressing HOME or END types a "~".  

I have a Linux box which I've logged into via PuTTY, and this problem doesn't exist.  So I figure it must be a setting in the OS.  Anyone have any idea how to get HOME and END to work?

Thanks,
Jay


----------



## randux (Jul 27, 2011)

Bash *usually* defaults to emacs key bindings. ctrl-a will get you to the beginning of the line and crtl-e goes to the end. This *usually* works, but not always. I haven't figured out which scenarios cause problems but most of the time it works. In your case I don't know if it's putty or the shell that's doing it, but you could try the control keys and see if they work. If not, you should look at the putty doc.


----------



## SirDice (Jul 28, 2011)

Putty has various settings to map the HOME and END key. I forgot what setting they're supposed to be, I'll have a look when I get to work.


----------



## notfed (Jul 28, 2011)

So, CTRL+A and CTRL+E work, thanks!  I'll have to get used to that for now.

It would still be helpful if someone could help me figure out how to map the HOME and END keys!


----------



## SirDice (Jul 28, 2011)

notfed said:
			
		

> It would still be helpful if someone could help me figure out how to map the HOME and END keys!


I could have sworn this used to work out of the box. Setting PuTTY to use the rxvt encoding for HOME and END makes the HOME key work. END however still doesn't work correctly.

I have had a similar issue with Solaris. In the end I solved it by adding a few bindkey's to my shell startup script.

These are for (t)csh but bash has a similar command:

```
bindkey "^[[1~" beginning-of-line
                bindkey "^[[4~" end-of-line
                bindkey "^[[3~" delete-char
```


----------



## notfed (Jul 28, 2011)

Thank you, SirDice.  The following worked for Bash:


```
bind '"\e[1~": beginning-of-line'
bind '"\e[4~": end-of-line'
```


----------

