Terminal
Terminal & iTerm2 Keyboard Shortcuts
Essential keyboard shortcuts for Terminal, iTerm2, and common shell navigation - line editing, history, tabs, and panes.
Line Editing (Readline / Emacs Mode)
| Shortcut | Action |
|---|---|
Ctrl+A | Move cursor to beginning of line |
Ctrl+E | Move cursor to end of line |
Ctrl+F | Move cursor forward one character |
Ctrl+B | Move cursor backward one character |
Alt+F / Opt+F | Move forward one word |
Alt+B / Opt+B | Move backward one word |
Ctrl+U | Delete from cursor to beginning of line |
Ctrl+K | Delete from cursor to end of line |
Ctrl+W | Delete word before cursor |
Alt+D / Opt+D | Delete word after cursor |
Ctrl+D | Delete character under cursor (or exit shell) |
Ctrl+H | Delete character before cursor (backspace) |
Ctrl+T | Transpose characters |
Alt+T / Opt+T | Transpose words |
Ctrl+Y | Paste (yank) last deleted text |
Alt+Y / Opt+Y | Cycle through yank ring |
Ctrl+_ | Undo last edit |
Ctrl+XX | Toggle between cursor position and beginning of line |
History
| Shortcut | Action |
|---|---|
Ctrl+R | Reverse search history |
Ctrl+S | Forward search history |
Ctrl+P / Up | Previous command in history |
Ctrl+N / Down | Next command in history |
Alt+. / Opt+. | Insert last argument of previous command |
!! | Repeat last command |
!$ | Last argument of previous command |
!* | All arguments of previous command |
!abc | Run last command starting with “abc” |
^old^new | Replace “old” with “new” in last command |
Ctrl+G | Cancel history search |
history | Show full command history |
Process Control
| Shortcut | Action |
|---|---|
Ctrl+C | Kill current foreground process |
Ctrl+Z | Suspend current process (background) |
Ctrl+D | Send EOF (exit shell if line is empty) |
Ctrl+S | Pause terminal output |
Ctrl+Q | Resume terminal output |
Ctrl+L | Clear screen (keep history) |
fg | Resume suspended job in foreground |
bg | Resume suspended job in background |
jobs | List background jobs |
iTerm2 Specific
| Shortcut | Action |
|---|---|
Cmd+T | New tab |
Cmd+W | Close tab/pane |
Cmd+D | Split pane vertically |
Cmd+Shift+D | Split pane horizontally |
Cmd+] | Next pane |
Cmd+[ | Previous pane |
Cmd+Opt+Arrow | Navigate between panes |
Cmd+Shift+Enter | Maximize/restore pane |
Cmd+Left / Cmd+Right | Switch tabs |
Cmd+1-9 | Jump to tab by number |
Cmd+F | Find in terminal |
Cmd+Shift+H | Paste history |
Cmd+; | Autocomplete |
Cmd+Opt+E | Expose all tabs |
Cmd+/ | Find cursor |
Cmd+Enter | Toggle fullscreen |
Cmd+Shift+I | Broadcast input to all panes |
Cmd+K | Clear buffer |
Cmd+Shift+O | Open quickly (search sessions) |
macOS Terminal.app
| Shortcut | Action |
|---|---|
Cmd+T | New tab |
Cmd+N | New window |
Cmd+W | Close tab |
Cmd+Shift+Left/Right | Switch tabs |
Cmd+D | Split window (macOS Sequoia+) |
Cmd+K | Clear to start |
Cmd+, | Preferences |
Cmd+I | Inspector (window info) |
Useful Shell Aliases
| Alias/Command | Action |
|---|---|
alias ll='ls -la' | Long listing with hidden files |
alias ..='cd ..' | Go up one directory |
alias ...='cd ../..' | Go up two directories |
alias gs='git status' | Git status shortcut |
alias gp='git push' | Git push shortcut |
Ctrl+R then type | Fuzzy search command history |
cd - | Return to previous directory |
pushd / popd | Directory stack navigation |