Fixing Home, End, Page Up, and Page Down in Leopard’s Terminal

Well, if you’re like me, you used to be pro-Windows. Then you found and fell in love with Linux. Then you realized how complicated it was to emulate your Windows software in a Linux environment, or get the Broadcom wireless card on your Dell laptop to work.

Then you discovered the Mac. Sleek. Sexy. Expensive… and the best of both worlds. A Unix-based platform, native Adobe apps, [paid] support, and a real terminal!

But wait, trouble in paradise — our favorite Windows/Linux key commands (Home, End, Page Up, Page Down) aren’t working as inspected. In fact they’re different throughout the OS.

Well, kids, after researching, I’ve finally got a working solution for Terminal.app:

  1. Open Terminal.app
  2. Open the Preferences window (CMD+,)
  3. Click the Settings tab
  4. Select your current Settings theme, and click on the Keyboard tab
  5. Edit (or Add) the entry for Home
    • Set Action: to send string to shell:
    • Set the string to \001 (or press Ctrl+a)
  6. Edit (or Add) the entry for End
    • Set Action: to send string to shell:
    • Set the string to \005 (or press Ctrl+e)
  7. Edit (or Add) the entry for Page Up
    • Set Action: to send string to shell:
    • Set the string to \033[5~ (copy and paste this in)
  8. Edit (or Add) the entry for Page Down
    • Set Action: to send string to shell:
    • Set the string to \033[6~ (copy and paste this in)
  9. Close the settings window.

There you go. Terminal should be ready to use the Home, End, Page Up, and Page Down keys as expected by Windows/Linux users.

SSH into your favorite Linux server, open nano, vi, or emacs and enjoy.

These articles made this article possible:

12 Comments

  1. Breakpoint says…

    Close, but no cigar on the Home and End keys, at least for vim. Try these instead:

    Home: 33[7~
    End: 33[4~

    Enjoy!

  2. Breakpoint says…

    Damn, the comment processor was not written with proper techs in mind! Make those as they are in the article:

    Home:
    backslash zero three three left-square-bracket seven tilde

    End:
    backslash zero three three left-square-bracket four tilde

    …hopefully that also clarifies things for those of you having unicode issues with the preceding. =]

  3. andy says…

    @breakpoint thanks, mine works great for basic terminal work as well as nano. Haven’t tried vim though.

    Thanks for the additional info, not sure why WP killed your slash. Probably something to do with it’s slash escaping through GET/POST requests.

  4. koz says…

    saved me allot of frustration on my MBP!

    except i set ctrl+up to page up etc etc

    you rock!

  5. meeba says…

    Woo!! Breakpoint in the house!!!!! Almost every site out there has the quick fix with ctrl+a and ctrl+e but does NOT work in vi. I copy/pasted your home and end codes and they worked great in vi both in normal mode and insert mode. Rock! Thank you!

  6. meeba says…

    oops just noticed that unfortunately the vi fix doesn’t work with home/end in Terminal. it just prints out a “~” doh!

  7. Doc says…

    Yeah, these mappings are good for use in VI and some other command line apps, but indeed, it doesn’t actually work (home/end) in the terminal itself. I seriously can’t stand how this is even a problem. Ugh, Apple, you do so well in general, but this is actually a point of real frustration for me!

  8. Olof says…

    Great tip, this one actually works in VI!!!

  9. MB says…

    this is driving me mad…

  10. Ted R. says…

    I hate Macs. The most counter intutitve devices ever made.

  11. andy says…

    @Ted, easily a million people out there to discount that statement without clarification/details ;p

  12. nikhil says…

    Awesome! thanks! this saved me a lot of time and frustration.

RSS feed for comments on this post. TrackBack URL

Leave a Comment

February 17, 2009

Filed in Uncategorized

There are 12 comments »


« Back to the Blog