jump to navigation

Sanity re: home & end on osx 2006 May 30 22:49

Posted by diamond in : Random , 4 comments

Steps required to get the home and end keys doing something useful in Terminal.app on osx:

  1. Go to the keystrokes editor (Terminal->Window Preferences->Keyboard)
  2. Select ‘end’ in the ‘Key Mappings’ list, click edit
  3. Change the action to ’send string to shell:’
  4. Set the string by hitting the following keys (without spaces): esc [ 4 ~
  5. Click ‘OK’
  6. Select ‘home’ in the ‘Key Mappings’ list, click edit
  7. Change the action to ’send string to shell:’
  8. 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?’.