Keyboard Shortcuts

these are readline shortcuts. they work in bash and mostly in zsh too. you don’t need to memorize all of them — just pick a few and they’ll become muscle memory in like a week.

moving around

  • Ctrl+A — jump to start of line
  • Ctrl+E — jump to end
  • Alt+F / Alt+B — move forward/back one word

I remapped caps lock to ctrl years ago and it made all of these way more comfortable. highly recommend.

deleting stuff

  • Ctrl+W — delete word before cursor
  • Ctrl+U — nuke everything before cursor
  • Ctrl+K — nuke everything after cursor
  • Ctrl+Y — paste back what you just nuked

the nice thing is these are actually cut operations, not delete. so Ctrl+U then Ctrl+Y is basically cut and paste. I use this when I start typing a command, realize I need to do something else first, Ctrl+U to stash it, do the other thing, then Ctrl+Y to bring it back.

the big one: Ctrl+R

reverse search through your history. just start typing and it finds matching commands:

(reverse-i-search)`deploy': ./deploy.sh production

press Ctrl+R again to go further back. Enter to run it, Ctrl+G to bail out.

this replaces like 90% of what you’d use bash-history-expansion for honestly.

Alt+. (the other big one)

inserts the last argument of the previous command. same as !$ but interactive — and if you keep pressing it, it cycles through older commands’ last args. super handy.

process stuff

  • Ctrl+C — kill it
  • Ctrl+Z — suspend it (then bg or fg, see bash-process-tricks)
  • Ctrl+D — EOF / close shell
  • Ctrl+L — clear screen

see also: bash-history-expansion, bash-process-tricks, bash-quick-loops

more shortcuts than you’ll ever need: catonmat readline cheat sheet