I remember the first time I opened the Terminal app on my 2013 MacBook Air. I was certain that I was one wrong command away from breaking everything. I didn't understand why I would use a terminal when I could use Apple's Finder GUI to open or move a file.
I felt trapped by the fact that I couldn't use my mouse to move my cursor. If I pasted a command that I didn't want to run, I would delete each character one at a time because I didn't know how to do anything differently. I stayed in that state for way too long. Don't make my mistake. Take ten minutes to memorize a few key bindings.
This document was last updated on 20 MARCH 2022
ctrl + c
— Terminate whatever process is currently running in the foreground. Is your shell doing something and you wish it would stop? ctrl + c
Did you paste a command that you don't want to run and now you want a fresh command line to type a different command? ctrl + c
"C" for "give me back Control of my command line."ctrl + r
— Open "reverse-i-search". Have you run a command in the past and now you'd like to run it again? If you're lucky and have run the command recently, you could up arrow all the way back to it. A better approach is to use ctrl + r
to open "reverse-i-search". Once you've typed ctrl + r
, start typing the command you're looking for. If you open "reverse-i-search" and then change your mind about seaching for a past command, type ctrl + c
to terminate search mode. "R" for "reverse search"ctrl + a
— Go to the beginning of the command line. If you have a big command typed out and then realize you need to change something at the very beginning of the command, you could left arrow your way there one character at a time, or you could ctrl + a
to hop straight there. "A" like the beginning of the alphabet.ctrl + e
— Go to the end of the current command, opposite of ctrl + a
"E" for "end."ctrl + w
— Delete whatever you have typed into the command line one word at a time, moving backwards from wherever the cursor currently is. "W" for "word."Write it on a post-it note and post it on your monitor until you've built up the muscle memory. When you've got these five memorized, find five more and repeat the process.
ctrl + c - regain control
ctrl + r - reverse search
ctrl + a - go to the beginning of the command
ctrl + e - go to the end of the command
ctrl + w - delete one word