Press Home or End Button to Navigate to the Beginning or End of Line in zsh

Wed Jan 04 2023

I've been using zsh with starship prompt for a while. One small pain is that home and end button doesn't navigate the cursor to the beginning or end of the command line. It's the muscle memory from using bash.

I didn't get it fixed for a long time, I thought it was a hotkey issue of the terminal emulator and I never found the option to fix it in preferences.

Until today, I tried to google it, turns out that it's a zsh hotkey binding issue.

To fix it, add the following line to ~/.zshrc:

zsh
|
bindkey "^[[H" beginning-of-line bindkey "^[[F" end-of-line

References