8

I switched to ZSH from BASH as per the upgrade in Catalina and all is well except my home/end keys no longer work. This can be really annoying trying to move my cursor over super far to the left instead of a single home click.

Any idea if they just changed the key you use to "go to start of command" instead of home? Or is there a bug?

1
10

The other answers didn't work for me when connecting over SSH to the Mac. I had to add the following lines to my ~/.zshrc to get Home and End to work:

bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
5

It seems the control characters required for zsh in Terminal are slightly different than the ones that worked in bash.

To fix your Home/End keys:

  1. Open Terminal -> Preferences...
  2. Select your preferred profile
  3. On the Keyboard tab, add a new binding (or modify an existing one)
  4. Use the following settings to make Home work again:
    • Key: Home (↖)
    • Modifier: None
    • Action: Send Text
    • Text to send is \033[1~ (For bash, \033OH was the value that worked)
  5. Use the following settings to fix the End key:
    • Key: End (↗)
    • Modifier: None
    • Action: Send Text
    • Text to send is \033[4~ (For bash, \033OF was value that worked)

This fixes my Home/End keys in zsh, and also works correctly when connected over SSH to terminals running bash.

Note that if you have keybindings specified in your ~/.zshrc or are running a third-party software to adjust your keybindings globally (eg: Karabiner), you might need to check or undo any settings in those places that may affect the Home/End keys if you're getting weird behaviour.

2

@jemcclin's answer did not work for me. Here's what worked for me on latest macOS Catalina 10.15.5

  1. Open Terminal -> Preferences...

  2. Select your preferred profile

  3. On the Keyboard tab, add a new binding (or modify an existing one)

  4. Use the following settings to make Home work again:

    • Key: Home (↖)
    • Modifier: None
    • Action: Send Text
    • Text to send is \001 (CTRL+A)
  5. Use the following settings to fix the End key:

    • Key: End (↗)
    • Modifier: None
    • Action: Send Text
    • Text to send is \005 (CTRL+E)

Extra: btw, i was having the same Home/"Scroll to top" issues on webpage forms (like the one i'm typing right now to answer this) and what fixed for me was this

https://www.iexplain.org/remap-home-and-end-buttons-for-external-keyboard-on-mac/

1

@jemcclin's answer requires the following entries in ~/.zshrc to work

bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
2
  • Thanks! If you ever want to edit another answer to clarify, that’s encouraged as well as posting an answer. – bmike Apr 9 '20 at 17:38
  • 1
    Thanks Mike. I wasn't aware that answer-editing was a thing for novice users. But I'll consider that option if the need arises again. (I went for a 2nd answer, because my reputation was too low to add a simple comment) – frame Apr 10 '20 at 13:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .