macOS Terminal cheat sheet
The Terminal on macOS offers quite an amount of functionality, but most of it is hard to discover unless you already know what you’re looking for. So here’s a quick cheat sheet explaining unique functions with their corresponding key combos:
Marks
Marks allow you to mark certain lines in the output, and allow you to jump between different parts of the output.
By default, every time you hit enter on your prompt, Terminal will automatically insert a mark for you. You can configure this in the Edit
menu, under Marks
with the option Automatically Mark Prompt Lines
.
Marks are visualised in the Terminal window as light grey square brackets (They are not, however, part of the output).
Cmd-⬆
: Jump to previous markCmd-⬇
: Jump to next markCmd-Shift-A
: Selects the output between the current marksCmd-Enter
:Enter
, and will always create a markCmd-Shift-Enter
:Enter
, but will never create a markCmd-U
: Create markCmd-Shift-U
: Remove markCmd-L
: Clear screen to previous mark
Bookmarks
Similar to marks, they can optionally be named, and are more useful to denote larger sections of the output. They are denoted by light grey bars.
Cmd-Shift-M
: Insert BookmarkCmd-Option-U
: Mark current line as bookmarkCmd-Shift-Option-M
: Insert named bookmarkCmd-Option-⬆
: Jump to previous bookmarkCmd-Option-⬇
: Jump to next bookmarkCmd-Option-L
: Clear to previous bookmark
Panes
View different parts of the scrollback buffer of the same terminal.
Cmd-D
: Split window into panesCmd-Shift-D
: close split pane
Miscellaneous
Cmd-K
: Clear everythingCmd-Option-K
: Clear scroll back (everything except what you see on the screen)Cmd-Option-O
: Toggle use of option as meta keyCmd-Ctrl-V
: Paste escaped text. Useful for pasting e.g. paths containing whitespace.Cmd-Shift-Option-C
: Copy as plain textCmd-Option-PageUp
orPageDown
: Scroll one line up/downCmd-[
or]
: Switch between windowsCmd-Shift-[
or]
: Switch between tabs
(Some of this I learned from mjtsai’s post Mac Terminal Tips, which is a great jumping off point for further interesting things the Terminal can do)