11

On a Macbook Pro keyboard, how do you go the the end-of-line and beginning-of-line in Terminal.app?

Note that Ctrl-a and Ctrl-e on this computer with default configuration does not work. They just echo "^A" and "^E"....

Terminal 2.1.1 ; Snow Leopard ; MacBookPro6,2

1
  • One might think this is an established answer or a duplicate question, but every answer I've come across either does not work (perhaps only for the macbook pro keyboard), or doesn't clearly describe how to enter keyboard escape sequences, or is missing other crucial info or isn't expressed in simplest terms.
    – malatio
    Nov 27 '10 at 1:34
22

Ctrl + a and Ctrl + e for beginning and end respectively.

Bonus: Ctrl + w deletes the previous word.

EDIT: As far as I can tell, you are using the zsh shell, which by default does not use Emacs key bindings. To get the behaviour you want, do the following during your session:

echo "bindkey -e" >> ~/.zshrc && source ~/.zshrc

You should be good to do. For more keybinding information, please check the relevant section from the Zsh manual.

8
  • 1
    More Readline keybindings: tiswww.case.edu/php/chet/readline/rluserman.html By default, these are mostly inspired by Emacs movement and editing shortcuts.
    – ephemient
    Nov 27 '10 at 3:52
  • That pesky Ctrl key confuses me when I'm switching between XP on VirtualBox, Mac OS X and Terminal.app ... but at least Ctrl + a and Ctrl + e is consistent across most terminals. +1 for you.
    – user3463
    Nov 27 '10 at 4:24
  • I don't much like the use of Ctrl for this either, but I agree there's a reason to keep it this way instead of using Cmd.
    – roguesys
    Nov 27 '10 at 4:53
  • Yeah this doesn't work on my new macbook pro running snow leopard. I get "^A" in the terminal when typing Ctrl-a, etc... So I'm still looking for the right answer :(
    – malatio
    Nov 29 '10 at 6:28
  • This really is the correct answer, check on your setup if it doesn't work -- in my case I was running zsh with some funny bindings. So not to be bash-centric, but be careful with your setup if you're not using default bash with the default .profile if this doesn't work. One note, I belive these are features of bash, not terminal.app, there are ways to adjust your terminal.app and/or os settings to select your own keycodes to send in to the terminal, but it all gets very complicated.
    – malatio
    Nov 30 '10 at 19:43
3

fn+ and fn+ work for me (they represent Home and End respectively).

More convenient than ctrl+A and ctrl+E in my opinion.

1
  • Really? That seems odd to me, since both fn and arrows are farther away from the center of the keyboard... but it doesn't exactly matter, since the question isn't "how do I type like Patrick?". ctrl-A and ctrl-E aren't widely used but have a following going way back; there's a contingent of bearded keyboardists who do use it.
    – malatio
    Mar 31 '15 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.