Sanity re: home & end on osx 2006 May 30 22:49
Posted by diamond in : Random , trackbackSteps required to get the home and end keys doing something useful in Terminal.app on osx:
- Go to the keystrokes editor (Terminal->Window Preferences->Keyboard)
- Select ‘end’ in the ‘Key Mappings’ list, click edit
- Change the action to ’send string to shell:’
- Set the string by hitting the following keys (without spaces): esc [ 4 ~
- Click ‘OK’
- Select ‘home’ in the ‘Key Mappings’ list, click edit
- Change the action to ’send string to shell:’
- Set the string by hitting the following keys (without spaces): esc [ 1 ~
Ok. That’s enough to get the keystrokes to be sent correctly to your shell, and any apps you’re running in it. To get your shell to do something useful with those keystrokes, you probably want something like this in your ~/.inputrc file:
# some defaults / modifications for the emacs mode
$if mode=emacs
# allow the use of the Home/End keys
“\e[1~”: beginning-of-line
“\e[4~”: end-of-line
$endif
*shakes fist at wordpress that it doesn’t respect the indentation of stuff inside code tags*
For this to take effect you’ll need to start a new shell. If you’re not using bash, the question would be ‘why?’.

Comments»
Thank you _so_ much!
You’ve inadvertentely saved numerous small defenceless fluffy animals from slaughter due to my frustration on this one.
Your place in paradise is secured.
Disclaimer: Yes, I am actually sane, I’m a Vi(m) user
What’s wrong with just using ^A and ^E? - Sure, they’re Emacs bindings, but they work in any shell and on any system (although you may need to tweak a few knobs in zsh on Solaris, but no surprises there) and on any keyboard layout. (my PowerBook required Fn to enable to Home and End)
They’re two of my most used control signals, right up there with ^C, ^W, ^T (sorry, BSD mannerism) and the occasional ^U…
Conal:
^A and ^E might work in shells, but they don’t work in simple things like, you know, text editors. I don’t see why i have to learn a different set of keystrokes for achieving the exact same purpose.
I do use ^C, ^W, ^U a lot. They are most useful. ^W is a slightly dangerous one to get used to though as in many gui environments it’ll do Bad Things when you’re just trying to delete a word -)
Who’s crazy enough to use a GUI interface when they’re a command line junkie?!?