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 lineCtrl+E— jump to endAlt+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 cursorCtrl+U— nuke everything before cursorCtrl+K— nuke everything after cursorCtrl+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 itCtrl+Z— suspend it (thenbgorfg, see bash-process-tricks)Ctrl+D— EOF / close shellCtrl+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