/mac-terminal-shortcuts

Useful and common terminal shortcuts for macOS

MIT LicenseMIT

Mac Terminal Shortcuts

A list of useful terminal shortcuts for macOS. Some obscure shortcuts like capitalizing words are purposely omitted.

Note: To use the Alt Key Shortcuts in macOS:

Open Terminal > Preferences > Profiles Tab > Keyboard Tab > Check "Use option as meta key"

Cursor Movement

Shortcut Description
Ctrl + E Move cursor to end of the line
Ctrl + A Move cursor to start of the line
Ctrl + F Move cursor one character forward
Ctrl + B Move cursor one character backward
Alt + F / Alt + Right Move cursor one word forward
Alt + B / Alt + Left Move cursor one word backward
Alt + Click Move cursor to clicked character
Ctrl + XX Toggle between the start of line and cursor position

Editing

Commands with "Cut" will add the cut portion to the clipboard.

Shortcut Description
Ctrl + L Clears the screen
Ctrl + D Delete character under the cursor
Ctrl + H Delete character before the cursor
Ctrl + K Cut everything from the cursor to end of the line
Ctrl + W / Alt + Backspace Cut the current word before the cursor
Alt + D Delete the word after the cursor
Ctrl + U Cut the line before the cursor
Ctrl + Y Paste the previous cut text
Ctrl + _ Undo your last key press. You can repeat this to undo multiple times
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor

History

Shortcut Description
Ctrl + P Previous command
Ctrl + R Next command
Ctrl + S Forward search
Ctrl + R Reverse search
Ctrl + O End search and execute command
Ctrl + G Abort search (restores original line)

Process

Shortcut Description
Ctrl + C Kills current task (SIGINT)
Ctrl + D Inserts an EOF
Ctrl + Z Pauses current task
Ctrl + S Stop output to the screen (for long running verbose commands)
Ctrl + Q Allow output to the screen (if previously stopped using stop output command)