How to do Home and End in iterm2

itermkeybindings

Home and End do nothing in iTerm2, nor do ⌘← and ⌘→.

However, Ctrl-A and Ctrl-E do work.

Can Home and End do this?

Preferences->Keys_Key Bindings in iTerm2 do not offer a "Start of Line" or "End of Line option.

Related: 1, 2

Best Answer

^ ControlA and ^ ControlE are keybinding in Bash and ZSH, not in iTerm (or Terminal).

If you want custom bindings within iTerm, you will need to bind the actual keyboard sequence in the keybinding. "Start of Line" and "End of Line" are descriptors, not the actual key strokes.

So, to do this you'd need to send ^ ControlA for Home via their Hex Codes. In this case, the codes would be 0x01 for "start of text" (^A) and 0x05 for "ENQ" (^E).

In the image below, you can add a new binding in Preferences → Keys → Key Bindings

  1. Click on + to add a new binding
  2. Click on Record in the dialog box
  3. Press your desired key (Home in this case).
  4. Select your Action (you can scroll or search). Select "Send Hex Code"
  5. Enter the Hex Code (0x01 for "start of text")
  6. Test it out!

iTerm2 Keybinding Home to ^A