Home and End Shortcuts in Terminal

TL;DR

Here are the shortcuts that will work in Terminal app.

Home: control + A

End: control + E

Next Word: esc, then f

Previous word: esc, then b

Why Bother

I like my shortcuts to be consistent across the most used applications: Chrome, Sublime Text 2 and iTerm. This way I don’t have to think about what application I’m in, and I can just hit the buttons.

I’ve set tab switch to option+command+left and option+command+right, home to command+left, and end to command+right and previous word to option+left, and next word to option+right. These shortcuts for the most part mimic the default behavior in Sublime Text 2 and other editors.

iTerm

iTerm is a better alternative to Terminal app on Mac OS X. You can get it at iterm2.com.

Home and End Shortcuts in iTerm

Home and End Shortcuts in iTerm

Go to your iTerm and open preferences from the menu (iTerm-> Preferences) or by using command + , or ⌘ + , shortcuts. Open Profiles tab and click on Keys for the Default profile.

To set home — that is, to jump to the beginning of a line — press command+left and then select ‘Send Hex Code’ and enter value 001.

Repeat the same thing for end substituting shortcut with command+right and hex with 005.

To set up previous word shortcut, press down option+left and then select ‘Send Escape Sequence’ and enter b. For the next word option+right shortcut, enter f.

Related posts:

I don’t know why Terminal and iTerm by default have broken shortcuts. Maybe there is some history to it, but it seems like I’m not the only person who has encountered (and/or fixed) the issue:

--
Best Regards,
Azat Mardan
Microsoft MVP | Book and Course Author | Software Engineering Leader
Azat Mardan avatar
https://www.linkedin.com/in/azatm
To contact Azat, the main author of this blog, submit the contact form or schedule a call at clarity.fm/azat and we can go over your bugs, questions and career.

Leave a Reply

Your email address will not be published. Required fields are marked *