markdown · 3643 bytes Raw Blame History

iTerm2 Reference

Terminal emulator for macOS with shell integration features.

Shell Integration

Installation:

# Already configured in ~/.config/fish/config.fish
source ~/.config/fish/iterm2_shell_integration.fish

What it does:

  • Marks command boundaries with escape sequences
  • Tracks command success/failure
  • Enables command navigation and output selection
  • Provides recent directory history

Command Navigation

Keybind Action
Cmd+Shift+Up Jump to previous command prompt
Cmd+Shift+Down Jump to next command prompt
Cmd+Shift+A Select output of last command
Cmd+Option+B Instant Replay (rewind terminal)

Visual Indicators:

  • Blue arrow in left margin = successful command
  • Red arrow = failed command
  • Right-click margin → Show Timestamps

Output Selection

Action Result
Cmd+Click on command Highlight that command's output
Double-click between prompts Select entire output block
Right-click output → Copy Output Copy just that command's output
Cmd+Shift+A Select output of last command

Directory Navigation

Keybind Action
Cmd+Option+/ Recent Directories popup
Cmd+Shift+B Toggle Toolbelt (includes Recent Directories)

Recent Directories:

  • Automatically tracks all directories you cd into
  • Press number key to jump to that directory
  • Searchable list

Split Panes

Keybind Action
Cmd+D Split horizontally (left/right)
Cmd+Shift+D Split vertically (top/bottom)
Cmd+Option+Arrow Navigate between panes
Cmd+Ctrl+Arrow Resize current pane
Cmd+Shift+Enter Maximize/restore current pane
Cmd+Option+E Broadcast input to all panes in tab

Tabs & Windows

Keybind Action
Cmd+T New tab
Cmd+N New window
Cmd+W Close tab/pane
Cmd+Shift+[ Previous tab
Cmd+Shift+] Next tab
Cmd+Number Jump to tab by number
Cmd+Option+Number Jump to window by number

Search & Selection

Keybind Action
Cmd+F Find/search
Cmd+E Use selection for find
Cmd+G Find next
Cmd+Shift+G Find previous
Cmd+Option+E Search in all tabs

Toolbelt (Sidebar)

Keybind Action
Cmd+Shift+B Toggle toolbelt

Toolbelt Features:

  • Recent Directories (click to cd)
  • Command History (searchable)
  • Recent Commands
  • Notes
  • Jobs

Useful Features

Triggers:

  • iTerm2 → Preferences → Profiles → Advanced → Triggers
  • Auto-detect patterns and take actions
  • Example: Highlight lines with "ERROR" in red
  • Example: Send notification when "Build complete" appears

Automatic Profile Switching:

  • iTerm2 → Preferences → Profiles → Advanced → Automatic Profile Switching
  • Switch profiles based on hostname, username, directory
  • Useful for different colors on production vs dev servers

Instant Replay:

  • Cmd+Option+B - Scrub backwards through terminal history
  • Like a DVR for your terminal
  • ESC to exit replay mode

Paste History:

  • Cmd+Shift+H - Show paste history
  • Search and re-paste previous clipboard contents

Configuration

Preferences Location:

  • Default: ~/Library/Preferences/com.googlecode.iterm2.plist (binary)
  • Custom: iTerm2 → Preferences → General → Preferences → Load from custom folder

Dynamic Profiles:

  • ~/Library/Application Support/iTerm2/DynamicProfiles/
  • JSON-based profile definitions
  • Version control friendly
View source
1 # iTerm2 Reference
2
3 Terminal emulator for macOS with shell integration features.
4
5 ## Shell Integration
6
7 **Installation:**
8 ```fish
9 # Already configured in ~/.config/fish/config.fish
10 source ~/.config/fish/iterm2_shell_integration.fish
11 ```
12
13 **What it does:**
14 - Marks command boundaries with escape sequences
15 - Tracks command success/failure
16 - Enables command navigation and output selection
17 - Provides recent directory history
18
19 ## Command Navigation
20
21 | Keybind | Action |
22 |---------|--------|
23 | `Cmd+Shift+Up` | Jump to previous command prompt |
24 | `Cmd+Shift+Down` | Jump to next command prompt |
25 | `Cmd+Shift+A` | Select output of last command |
26 | `Cmd+Option+B` | Instant Replay (rewind terminal) |
27
28 **Visual Indicators:**
29 - Blue arrow in left margin = successful command
30 - Red arrow = failed command
31 - Right-click margin → Show Timestamps
32
33 ## Output Selection
34
35 | Action | Result |
36 |--------|--------|
37 | `Cmd+Click` on command | Highlight that command's output |
38 | Double-click between prompts | Select entire output block |
39 | Right-click output → Copy Output | Copy just that command's output |
40 | `Cmd+Shift+A` | Select output of last command |
41
42 ## Directory Navigation
43
44 | Keybind | Action |
45 |---------|--------|
46 | `Cmd+Option+/` | Recent Directories popup |
47 | `Cmd+Shift+B` | Toggle Toolbelt (includes Recent Directories) |
48
49 **Recent Directories:**
50 - Automatically tracks all directories you `cd` into
51 - Press number key to jump to that directory
52 - Searchable list
53
54 ## Split Panes
55
56 | Keybind | Action |
57 |---------|--------|
58 | `Cmd+D` | Split horizontally (left/right) |
59 | `Cmd+Shift+D` | Split vertically (top/bottom) |
60 | `Cmd+Option+Arrow` | Navigate between panes |
61 | `Cmd+Ctrl+Arrow` | Resize current pane |
62 | `Cmd+Shift+Enter` | Maximize/restore current pane |
63 | `Cmd+Option+E` | Broadcast input to all panes in tab |
64
65 ## Tabs & Windows
66
67 | Keybind | Action |
68 |---------|--------|
69 | `Cmd+T` | New tab |
70 | `Cmd+N` | New window |
71 | `Cmd+W` | Close tab/pane |
72 | `Cmd+Shift+[` | Previous tab |
73 | `Cmd+Shift+]` | Next tab |
74 | `Cmd+Number` | Jump to tab by number |
75 | `Cmd+Option+Number` | Jump to window by number |
76
77 ## Search & Selection
78
79 | Keybind | Action |
80 |---------|--------|
81 | `Cmd+F` | Find/search |
82 | `Cmd+E` | Use selection for find |
83 | `Cmd+G` | Find next |
84 | `Cmd+Shift+G` | Find previous |
85 | `Cmd+Option+E` | Search in all tabs |
86
87 ## Toolbelt (Sidebar)
88
89 | Keybind | Action |
90 |---------|--------|
91 | `Cmd+Shift+B` | Toggle toolbelt |
92
93 **Toolbelt Features:**
94 - Recent Directories (click to `cd`)
95 - Command History (searchable)
96 - Recent Commands
97 - Notes
98 - Jobs
99
100 ## Useful Features
101
102 **Triggers:**
103 - iTerm2 → Preferences → Profiles → Advanced → Triggers
104 - Auto-detect patterns and take actions
105 - Example: Highlight lines with "ERROR" in red
106 - Example: Send notification when "Build complete" appears
107
108 **Automatic Profile Switching:**
109 - iTerm2 → Preferences → Profiles → Advanced → Automatic Profile Switching
110 - Switch profiles based on hostname, username, directory
111 - Useful for different colors on production vs dev servers
112
113 **Instant Replay:**
114 - `Cmd+Option+B` - Scrub backwards through terminal history
115 - Like a DVR for your terminal
116 - ESC to exit replay mode
117
118 **Paste History:**
119 - `Cmd+Shift+H` - Show paste history
120 - Search and re-paste previous clipboard contents
121
122 ## Configuration
123
124 **Preferences Location:**
125 - Default: `~/Library/Preferences/com.googlecode.iterm2.plist` (binary)
126 - Custom: iTerm2 → Preferences → General → Preferences → Load from custom folder
127
128 **Dynamic Profiles:**
129 - `~/Library/Application Support/iTerm2/DynamicProfiles/`
130 - JSON-based profile definitions
131 - Version control friendly