Apple - Can home and end keys be mapped when using Terminal?

To answer the one about how to get the beginning or end of the line, it appears that by default Terminal maps these keys to it:

  • shift+home → beginning of line, equivalent to the "home" key in normal terminals
  • shift+end → end of line, equivalent to the "end" key in normal terminals

If you want home and end to work the "normal" way (and not require shift), go to [Terminal menu] → Preferences → Profiles tab (or settings on some versions of OS X) → Keyboard sub-tab.

Then modify/add these keys to be the following "send string to shell"

  • home: \033[H
  • end: \033[F

You can get the \033 part by hitting the escape key within the edit dialog input, if you need to add it.

Then home and end will work like normal again (phew).

Also note that "alt + ←" and "alt + →" by default in terminal map to word left and word right, another handy combo to remember.

In later versions of Mac OS X, if the terminal screen shifts up or down when you press the home/end key, the home key may need to be set to \033[1~ and the end key to \033[4~ to get the results you want (no shift needed).

Feel free to modify this answer to add more useful key bindings, as it is a community wiki.


Use control+a for HOME and control+e for END in Terminal.

Also use esc+f to move to the beginning of the next word and esc+b to move to the beginning of the current word. (you Must be careful about current and next)


It sounds like you are looking for some help using readline and bash, here is an insane list of keyboard stuff modified from: http://www.math.utah.edu/docs/info/features_7.html#SEC45

Ctrla Move to the start of the line.
Ctrle Move to the end of the line.
Escf Move forward a word.
Escb Move backward a word.
Ctrll Clear the screen, reprinting the current line at the top.

Ctrlk Kill the text from the current cursor position to the end of the line.
Escd Kill from the cursor to the end of the current word, or if between words, to the end of the next word.
EscDel Kill from the cursor the start of the previous word, or if between words, to the start of the previous word.
Ctrlw Kill from the cursor to the previous whitespace. This is different than EscDelCtrla because the word boundaries differ.

Ctrld Delete the character underneath the cursor.
Ctrl_ Undo the last thing that you did. You can undo all the way back to an empty line.

And, here is how to yank the text back into the line. Yanking means to copy the most-recently-killed text from the kill buffer.

Ctrly Yank the most recently killed text back into the buffer at the cursor.
Escy Rotate the kill-ring, and yank the new top. You can only do this if the prior command is Ctrly or Escy.