2007-11-22

Configuring Mac OS X Terminal

I recently installed Leopard (Mac OSX 10.5) on a new mac. There are a few factory settings I usually change on a new installation, although by far fewer than I do typically with Windows. One of them is the default keyboard configuration for Ctrl+Left Arrow, Ctrl+Right Arrow, Page Up, Page Down, Home, and End in Terminal. The default settings drive me a bit potty since I'm used to using Linux and emacs every day at work.

Changing them is easy, fortunately. Just visit Keyboard under Settings in Terminal->Preferences, and modify the following keys, so that their action matches the value shown. You can edit the keystroke for an item by double clicking on it, selecting "send string to shell", and typing the indicated keys.

Key Action Keystrokes
control cursor left \033b ESC b
control cursor right \033f ESC f
end \005 CTRL+e
home \001 CTRL+a
page down \026 CTRL+v
page up \033v ESC v

AddThis Social Bookmark Button

13 comments:

  1. MarnenJan 3, 2008 09:34 AM
    This would be a good tip, if it weren't completely unnecessary. Every Mac OS X configuration I've ever set up or used had the Emacs keys already working in Bash right out of the box.
    ReplyDelete
  2. Brian DuffJan 4, 2008 02:52 AM
    not if you ssh into a Linux box from Console.
    ReplyDelete
  3. Brian DuffJan 4, 2008 02:55 AM
    ... And also home / end / page up / page down don't work in bash in Console the way they do in Linux.
    ReplyDelete
  4. AnonymousJan 13, 2008 12:52 PM
    This is a fantastic tip! I do all of my work on a remote linux box and feel like I spend a large chunk of my day scrolling through text. Thanks for saving me a lot of time.
    ReplyDelete
  5. janraJan 24, 2008 07:13 PM
    Do you happen to know the code that Tiger sent by default when you used pgup/pgdn? I think it was an actual pgup/pgdn character. One of the things I use via terminal is screen+irssi, and without my pgup/pgdn I don't have access to scrollback anymore with Leopard - note that irssi scrollback is different from terminal scrollback; shift-pgup/pgdn was what I always used to use to scroll through the terminal scrollback buffer.

    I tried just pressing the pgup/pgdn key, but nothing showed up in the field. (Note I'm on a laptop so I have to use fn-arrow, there is no separate key.)

    Thanks for any suggestions...
    ReplyDelete
  6. Scott GaschApr 3, 2008 09:14 PM
    An alternative: look at the termcap entry on the machine you are sshing into and change your cursor keys etc... to match:

    up: \033OA
    down: \033OB
    left: \033OD
    right: \033OC
    home: \033[1~
    end: \033[4~

    etc...
    ReplyDelete
  7. inakanetworks.comJul 31, 2008 08:00 AM
    my last macbook pro complaint is resolved. thanks!
    ReplyDelete
  8. AnonymousAug 8, 2008 10:24 AM
    Seems like Shift-Page(up/down) sends the right thing to bash :-)
    ReplyDelete
  9. mehxFeb 22, 2009 01:48 AM
    janra-

    I was fooling around with scrollback in irssi and found that shift+fn+pageup/down is used for scrollback.
    ReplyDelete
  10. TomApr 28, 2009 09:24 PM
    Great tip, thanks!
    ReplyDelete
  11. jjenseniiAug 21, 2009 10:32 AM
    Thank you! Now my Terminal finally behaves the way I expect it to.
    ReplyDelete
  12. AnonymousSep 11, 2009 09:17 AM
    Great, Thanks !
    ReplyDelete
  13. AnonymousOct 8, 2009 06:27 PM
    I have been complaining about this for years. Thank you
    ReplyDelete