Terminal keyboard shortcuts

Mac keyboard shortcuts

Keyboard Symbols

Symbol Key Symbol Key
⌘ Command ◀ Left Arrow
⌃ Control ▶ Right Arrow
⌥ Option ▲ Up Arrow
◇ Meta ▼ Down Arrow
⌫ Delete (Backspace) ⇥ Tab
↩ Return / Enter Fn Function

Common

Undo the last change (Bash and Zsh) ⌘ Z or ⌃ _
Paste last selected string ⌘ Right-click (Or middle mouse click, if any)

Bash / Zsh

Moving the Cursor

Go to beginning of line ⌘ ◀ or ⌃ A
Go to end of line ⌘ ▶ or ⌃ E
Forward one character ⌃ F
Back one character ⌃ B
Back one word ⌥ ◀ or ◇ B
Forward one word ⌥ ▶ or ◇ F
Move between the beginning of the line and the current cursor position ⌃ X⌃ X (Hold ⌃ and press X twice)

Delete Text

Delete the word before the cursor ⌥ ⌫ or ◇ ⌫
Delete the word after the cursor ◇ D
Delete the character under the cursor ⌃ D
Delete one character backwards ⌃ H or ⌫

Cutting and Pasting

Cut one word backwards, adding it to the clipboard ⌥ ⌫ or ⌃ W
Cut to end of line, adding it to the clipboard ⌃ K
Cut to beginning of line, adding it to the clipboard ⌃ U
Paste the last text you cut from the clipboard (yank) ⌃ Y

Capitalizing Characters

Uppercase every character from the cursor to the end of the current word ◇ U
Lowercase every character from the cursor to the end of the current word ◇ L
Capitalize the character under the cursor and move to the end of the word ◇ C

Swap Text

Swap current word with previous ◇ T
Swap the last two characters before the cursor ⌃ T

Tab Completion

Automatically complete the file, directory, or command you're typing ⇥

History Search

  1. Press ⌃ R to search through the history.
  2. Continue pressing ⌃ R until you find the entry you're looking for.
  3. Press ↩ to execute the current expression.
  4. Press ▶ to modify the current expression.
  5. Press ⌃ G to escape from search mode.

Screen Control

Clear screen ⌃ L
Stop output to screen (for long-running verbose commands) ⌃ S
Re-enable screen output ⌃ Q

Process Control

Kill current process ⌃ C
Exit shell ⌃ D
Suspend process ⌃ Z

Select Text in Alternate Screen

Modern terminals have two screen buffers:

  • Primary screen buffer, used by bash, zsh etc.
  • Alternate screen buffer, used by vim, nano, htop, less, screen, tmux etc.

While the alternate screen is displayed, mouse events may be captured by programs that support Mouse Reporting. In this case, press and hold the Fn key and drag to select text.

Meta Key ◇

To have the Option key on the keyboard act as a meta key, select “Use Option (⌥) as Meta key.” This is useful for computers running X11 and for some text editors.