Skip to content
Home » Mac Terminal Cheat Sheet: The Three Layers Behind Every Shortcut

Mac Terminal Cheat Sheet: The Three Layers Behind Every Shortcut

Dark reference card headed Mac Terminal cheat sheet with the line three layers decide what a keystroke does, showing three panels: shell examples from bindkey such as Control-A beginning-of-line, driver examples from stty such as intr equals Control-C, and app examples such as Command-T for a new tab

Mac Terminal shortcuts are not one list. They come from three separate layers of software stacked inside the same window, and a keystroke behaves differently depending on which layer catches it. That is why a shortcut a colleague swears by does nothing on your machine, why one of them appears to freeze the Terminal completely, and why some work over SSH on a Linux server while others stop at the edge of the window. This guide explains the three layers, walks through the situations where Terminal shortcuts actually save time, and ends with a cheat sheet you can keep open.

The three layers behind Terminal shortcuts

Understanding the layers is what turns a memorised list of Terminal shortcuts into something you can reason about, so it is worth three paragraphs before the keys themselves.

The Terminal app. Anything using the Command key is intercepted by the application before the shell sees it — new tabs, splitting the window, clearing the scrollback, font size. These Terminal shortcuts are menu items, so they change if you switch to a different terminal app, and they never reach a remote server.

The shell. zsh, the default shell on macOS, handles most Control combinations as line-editing commands. These are the Mac Terminal shortcuts worth investing in: they behave identically in any terminal app, inside tmux, and over SSH, because the shell doing the work is wherever your command line is.

The terminal driver. Below both sits the part of the operating system that turns keystrokes into signals. It owns a handful of the most important keys, and you can prove it: ask zsh what Control-C is bound to and it says nothing is there.

$ bindkey "^C"
"^C" undefined-key
$ bindkey "^Z"
"^Z" undefined-key

Unbound in the shell, yet both plainly do something. The driver caught them first, before zsh ever saw the keystroke. stty -a prints the full terminal settings; these are the eleven control characters it has claimed, pulled out of that output:

dsusp = ^Y
eof = ^D
erase = ^?
intr = ^C
kill = ^U
lnext = ^V
quit = ^\
start = ^Q
stop = ^S
susp = ^Z
werase = ^W

This is the layer nobody mentions, and it explains the two most alarming things that happen in a Terminal window. It is also why these particular keys work in places where the shell is not even involved, such as inside a text editor or a database client.

Terminal shortcuts for editing the line you are typing

This is where the shell layer earns its keep, and where most of the everyday Terminal shortcuts live. Four common scenarios cover almost all of it, and the same Terminal shortcuts apply whether you are on your own Mac or on a server.

You typed a long command and it needs sudo at the front. Press Control-A to jump to the start of the line, type sudo and a space, then Control-E to return to the end. No arrow keys, no mouse. This one scenario is why people learn Terminal shortcuts in the first place.

The last thing you typed is wrong. Control-W deletes the word before the cursor, so a mistyped filename disappears in one keystroke and you can retype just that part. Hold it down to walk backwards through the arguments one at a time.

You want that argument somewhere else. Control-W to cut it, move the cursor, then Control-Y to paste it back. Anything deleted with Control-W, Control-U, or Control-K goes into the same buffer, so Control-Y retrieves the most recent one.

You want to start over. Control-U clears the whole line at once. If you meant to keep it, Control-X followed by Control-U undoes the edit — one of the least known but most useful Terminal shortcuts on a Mac, since it also reverses an over-enthusiastic Control-W.

Two smaller ones round the set out. Control-K deletes from the cursor to the end of the line, which is how you trim a command back rather than clearing it. And Control-L clears the screen without touching what you have typed — the same result as running clear, except your half-finished command survives.

Getting a command back

Of all the Mac Terminal shortcuts on this page, Control-R is the one to learn first. Press it, then type any fragment of a command you have run before — the shell fills in the most recent match as you type. Press Control-R again to step further back through the matches, Return to run the one showing, or the right arrow to put it on the command line for editing first.

It replaces the habit of holding the up arrow, and the gap widens with every command you run. Searching for rsync finds the invocation with the flags you worked out three weeks ago, in about a second, without you remembering anything except that you did it once.

To back out of a search without running anything, Control-G cancels and restores the line you had. That is worth knowing, because pressing Escape or Control-C in the middle of a history search does not always leave things where you expect.

Terminal shortcuts for a command that is already running

Once a command is running, the shell is no longer reading your keystrokes — the driver layer is, and a different set of Terminal shortcuts applies.

  • Control-C — interrupt. Stops the running command and returns you to a prompt. Listed above as intr, and the first thing to try when something is taking longer than it should.
  • Control-Z — suspend. The command pauses rather than dying, and you get the prompt back. Type fg to resume it, or bg to let it continue in the background. This is the escape hatch when you started a long job and need the shell for one quick thing.
  • Control-D — end of input. On an empty line it closes the shell, which is a faster exit. Inside a program reading input, it signals that you are finished rather than killing anything.
  • Control-\ — quit. A blunter version of interrupt for a program ignoring Control-C. It is in the list as quit, and it is a last resort rather than a habit.

The distinction between the first two matters more than it looks. Control-C throws away whatever the command was doing; Control-Z keeps it alive and parked. For anything mid-download or mid-copy, suspending and resuming is usually what you actually wanted.

“My Terminal froze”

Here is the scenario that sends people searching for Mac Terminal shortcuts in the first place, usually described as the window having crashed. Look again at two lines from the driver’s list:

start = ^Q
stop = ^S

Control-S pauses output to the terminal. Nothing crashed, nothing is stuck — the driver is holding everything back, including the characters you type, so the window looks completely dead. Control-Q releases it and everything that piled up appears at once.

People hit this constantly by reaching for a save shortcut out of habit, and because the symptom looks like a crash, the usual response is to close the window and lose the session. One keystroke is the entire fix. This is a flow-control convention older than the Mac, which is exactly why it is still there and still surprising.

Checking any binding yourself

You do not have to trust any list of Mac Terminal shortcuts, including this one. zsh will tell you what a key does on your machine:

$ bindkey "^U"
"^U" kill-whole-line
$ bindkey -lL main
bindkey -A emacs main

The caret is how a Control key is written, so ^U means Control-U. The second command reports which keymap is in charge: emacs is the shipped default on macOS, and it is why these keys do these things. If yours answers viins, something in your configuration switched to vi-style editing and the shell-layer shortcuts here will not match until you switch back.

Bare bindkey prints everything — 117 entries in a shell started with no configuration at all. Filtering is more useful than reading it:

$ bindkey | grep '"\^W"'
"^W" backward-kill-word
Reference table titled zsh default key bindings, listing twenty key combinations with the zsh widget each is bound to and what it does, including Control-A as beginning-of-line, Control-W as backward-kill-word, Control-U as kill-whole-line, Control-R as history-incremental-search-backward and Option-. as insert-last-word
The shell layer in full, as bindkey reports it. Click to open the full-size image, or save it for reference.

This is also how you find out that a tip from elsewhere does not apply. Control-X Control-E, which opens the current command in your editor, is a bash habit that many articles repeat — in zsh the feature exists but no key is attached to it, so the keystroke does nothing until you add three lines to ~/.zshrc:

autoload -Uz edit-command-line
zle -N edit-command-line
bindkey "^X^E" edit-command-line

Changing a binding you do not like

Not every default suits everyone, and shell-layer Terminal shortcuts can be reassigned. zsh’s Control-U deletes the entire line, before and after the cursor. If you expected it to delete only backwards to the start of the line, one command changes it:

$ bindkey "^U" backward-kill-line
$ bindkey "^U"
"^U" backward-kill-line

Run it in a session to try it; add it to ~/.zshrc to keep it. The pattern is the same for any key — name the sequence, name the widget — and it is worth checking the existing binding first, because rebinding replaces whatever was there without a word. Note that this only works for the shell layer: the driver’s keys are set with stty, and the app’s are Terminal’s own menu shortcuts.

Window and tab shortcuts in Terminal

The Command-key Terminal shortcuts cover the window rather than the command line. Command-T opens a tab, Command-N a window, Command-W closes the tab. Command-K clears the scrollback completely, which is different from Control-L — the latter only scrolls the current screen out of the way, so the history is still there if you scroll up. Command-D splits the window into two panes over one session, and Command-Plus and Command-Minus change the font size.

Terminal also carries features most people never find, including marks and bookmarks — its menus include items such as Clear to Previous Mark and Clear to Selected Bookmark, which clear back to a point in the output instead of the whole buffer. Treat any published list of Command shortcuts as a starting point: the authoritative version for your Mac is the menu bar, where each shortcut is printed beside the item it triggers and always matches the release you are running.

Mac Terminal shortcuts cheat sheet

The complete set of Mac Terminal shortcuts covered above, grouped by the layer that handles them. The Layer column is the useful part: shell rows travel with you over SSH, driver rows work even inside other programs, and app rows stop at the edge of the window. The same cheat sheet is below as a single image if you would rather save or print it, followed by the text version for copying.

Mac Terminal cheat sheet grouped into three sections: shell keys handled by zsh line editing such as Control-A, Control-W and Control-R; driver keys handled by signals and flow control such as Control-C, Control-Z, Control-S and Control-Q; and app keys from Terminal menus such as Command-T, Command-K and Command-D
The full cheat sheet as a single image. Click to open it full size, or save it to keep alongside your terminal.
KeysWhat it doesLayer
Control-AMove to the start of the lineShell
Control-EMove to the end of the lineShell
Control-WDelete the word before the cursorShell
Control-UDelete the whole lineShell
Control-KDelete from the cursor to the endShell
Control-YPaste back what you last deletedShell
Control-RSearch command history backwardsShell
Control-GCancel a history searchShell
Control-LClear the screen, keep the typed lineShell
Control-X Control-UUndo the last edit to the lineShell
Control-CInterrupt the running commandDriver
Control-ZSuspend it; fg resumes, bg backgroundsDriver
Control-DEnd of input; closes the shell on an empty lineDriver
Control-SPause output — looks like a freezeDriver
Control-QResume output after Control-SDriver
Control-\Quit a program ignoring Control-CDriver
Command-T / Command-NNew tab / new windowApp
Command-WClose the tabApp
Command-KClear the scrollback entirelyApp
Command-DSplit the window into two panesApp
Command-Plus / Command-MinusFont sizeApp
bindkey "^X"Ask what a key is bound toShell

If you are starting from nothing, learn Control-R, Control-A, and Control-W first — between them they cover most of what slows people down. Then remember Control-Q, so the day the window appears to freeze you lose a second rather than a session. And when a shortcut from somewhere else refuses to work, bindkey with the key in question tells you in one line whether the article was wrong or your setup is different, which is more than any list of Mac Terminal shortcuts can do on its own.

Leave a Reply

Your email address will not be published. Required fields are marked *