Blog Ten terminal shortcuts that actually save time
Ten terminal shortcuts that actually save time
TL;DR The terminal gets a lot faster once a handful of shortcuts become reflex: jump to line start and end, delete by word, search your history, and reuse the last argument. Learn these ten and you stop retyping and start flying.
I spend a lot of the day in a terminal, and the difference between slow and fast is not typing speed. It is not retyping. These are the shortcuts I reach for without thinking. Learn them and the command line stops fighting you.
Most of these assume the default Emacs-style key bindings in bash and zsh.
Move around a line fast
- Ctrl-A jumps to the start of the line. Ctrl-E jumps to the end. Stop holding the arrow key.
- Alt-B and Alt-F move backward and forward one word at a time.
Delete without holding backspace
- Ctrl-W deletes the word before the cursor. Perfect for fixing the last thing you typed.
- Ctrl-U clears from the cursor to the start of the line. Great when you want to bail on a half-typed command.
- Ctrl-K clears from the cursor to the end.
Find old commands instantly
- Ctrl-R searches your history backward. Type part of a command and it surfaces. Press Ctrl-R again to step through older matches. This one alone is worth the whole list.
Reuse the last argument
- Alt-. (Alt and period) drops in the last argument of the previous command. Ran
mkdir some/long/path, now want tocdthere? Typecdthen Alt-period.
Fix a typo in the last command
^old^newreruns your last command with the firstoldreplaced bynew. Typedgit stauts? Just run^stauts^status.
Swap two characters
- Ctrl-T swaps the two characters around the cursor. Small, but it fixes the classic
tehslip without backspacing.
The habit that makes them work
Do not try to memorize ten shortcuts today. Pick two, tape them to the edge of your screen if you have to, and use them for a week even when your old way feels faster. Once they turn into reflex, add two more.
The goal is not to look fast. It is to keep your train of thought instead of breaking it to fight the cursor. A week of deliberate practice and these disappear into your hands, which is exactly where you want them.
FAQ
Do these shortcuts work in every shell?
Most work in bash and zsh out of the box, because both default to Emacs-style line editing. A few, like history search with Ctrl-R, are near universal. If you use Vi mode, the movement keys differ, but the history and argument tricks still apply.
What is the single most useful one to learn first?
Ctrl-R for reverse history search. Instead of pressing the up arrow twenty times, you type a few letters of a past command and it appears. It pays for itself the first day.
How do I make these stick?
Pick two at a time and force yourself to use them for a week, even when it feels slower. Once they are muscle memory, add two more. Trying to learn all ten at once rarely works.