While I've been an avid OSX fan since 2001, even I have to admit that the home/end keys on a Mac seem to be redundant. Whereas the PC keys help move the cursor to the start/end of a line, the Mac version jumps to the start/end of a document, which is something I never need to do.
Thankfully, it's possible to correct this. This code was originally written in 2012 (thanks to Matthew Holt) but works fine in all versions of Mac OSX.
1. Open the terminal.
2. Copy & paste each line, hitting Enter after each one:
cd ~/Library
mkdir KeyBindings
cd KeyBindings
nano DefaultKeyBinding.dict
This will open DefaultKeyBinding.dict in Terminal's Nano app. Paste the following text (including the braces):
{
/* Remap Home / End keys to be correct */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */
}
Press Ctrl+O and then Enter to save the file, and Ctrl+X to exit (and that is Ctrl, as the terminal doesn't use Command). It's best to restart to ensure the new setting works properly.