zsh: keyboard shortcuts

2020-10-16

 | 

~2 min read

 | 

281 words

Though potentially less daunting than Vim or Emacs, mastering zsh is a long road, but a few keyboard shortcuts can help to make you feel much more productive.

Two that I have looked up a number of times are jumping to the start and end of a line. I’ll probably have to look them up again in the future, but at least now I’ll have a place where I can keep track of the different keyboard shortcuts I come across for zsh.

Shortcuts

  • Ctrl A - Jump to the start of the line
  • Ctrl E - Jump to the end of the line
  • Ctrl F - Jump forward one character
  • Ctrl B - Jump backward one character
  • Alt F - Jump forward one word1
  • Alt B - Jump backward one word1

Editing

  • Ctrl U - Clear the entire line
  • Ctrl K - Clear line after the cursor
  • Ctrl W - Clear the word before the cursor
  • Ctrl R - Open Back Search. The back search allows you to search the zsh history for commands you’ve run in the past. If one is found, it will be populated on the line above the search and you can press Enter to execute. Interestingly, the search seems to take you to that point in history, meaning if you navigate with your arrow keys you will be navigating that part of zsh’s history.

Footnotes

  • 1 This one can be difficult with a Mac as Mac keyboards don’t come with an Alt key. To get it to work, you may need to remap your keyboard.


Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!