Shell integration enables advanced iTerm2 features like marks and command history tracking.
Enable Shell Integration
iTerm2 automatically installs shell integration. To manually enable:
curl -L https://iterm2.com/shell_integration/install_shell_integration.sh | bash
Key Commands
| Command | Purpose |
|---|---|
it2api |
Interact with iTerm2 from command line |
it2cmd |
Mark command boundaries |
iterm2_prompt_mark |
Manually set marks in shell prompt |
iterm2_get_pwd |
Get current working directory in iTerm2 |
Using Marks
Marks allow quick navigation between command outputs:
- Set mark: โโงM
- Jump to mark: โโงJ
- Next mark: โโฅ.
- Previous mark: โโฅ/
Profiles define terminal appearance, behavior, and key mappings.
Default Profile Locations
~/Library/Application Support/iTerm2/DynamicProfiles/
~/Library/Application Support/iTerm2/scripts/
Dynamic Profile JSON Structure
{
"Profiles": [
{
"Name": "My Profile",
"Guid": "profile-guid-12345",
"Command": "/bin/zsh",
"Working Directory": "/Users/username",
"Use Custom Font": true,
"Font Name": "JetBrains Mono",
"Font Size": 12,
"Character Encoding": 4,
"Color Preset Name": "Catppuccin Mocha",
"Background Color": {
"Red Component": 0.1,
"Green Component": 0.1,
"Blue Component": 0.12
}
}
]
}
Key Profile Settings
| Setting | Purpose |
|---|---|
Name |
Profile display name |
Guid |
Unique identifier |
Cursor Type |
Block, underline, or vertical bar |
Use Bold Font |
Enable bold text rendering |
Blinking Cursor |
Cursor animation toggle |
Scrollback Lines |
Terminal history buffer size |
Triggers automatically execute actions when terminal output matches patterns.
Access Triggers
Profile Settings โ Advanced โ Triggers
Common Trigger Patterns
| Pattern | Use Case |
|---|---|
error|ERROR|Error |
Highlight error messages |
warning|WARNING |
Highlight warnings |
^(.*)(passed|failed) |
Capture test results |
^prompt> |
Custom prompt detection |
Available Actions
| Action | Description |
|---|---|
| Highlight Text | Color code matching output |
| Capture Output | Save matched text to pasteboard |
| Run Command | Execute shell command |
| Show Alert | Display notification |
| Open URL | Launch URL in browser |
| Send Text | Send text to terminal |
| Bounce Dock Icon | Get user attention |
Example Trigger Setup
Pattern: npm ERR!
Action: Highlight Text (Red background)
Instant: Checked
iTerm2 integrates with tmux for enhanced terminal multiplexing.
Starting tmux with iTerm2
# Start new session with native iTerm2 integration
tmux -CC new-session -s main
# Attach to existing session
tmux -CC attach-session -t main
# New window in tmux session
tmux new-window -t main -n editor
Benefits of tmux Integration
- Native tab/pane support in iTerm2 UI
- Native search and copy/paste
- Profile settings applied per tmux pane
- Proper unicode and mouse support
- Automatic session persistence
tmux Dashboard
Access via: iTerm2 Menu โ tmux โ Dashboard
Shows all active tmux sessions with:
- Session names and window count
- Pane arrangement visualization
- Quick switch between sessions
Key Mappings
| Action | Default |
|---|---|
| Send command | โโฅC prefix |
| Detach session | โโฅD |
| List sessions | โโฅL |
iTerm2 supports displaying images and downloading files in the terminal.
Image Display Commands
# Display image using imgcat
imgcat ~/screenshot.png
# Inline image display
printf '\e]1337;File=name=filename;size=123456;base64=1:\n'
# Download file from URL
it2dl https://example.com/image.jpg
Supported Image Formats
| Format | Support | Notes |
|---|---|---|
| PNG | Full | Recommended format |
| JPEG | Full | Good compression |
| GIF | Full | Animated support |
| TIFF | Full | Lossless option |
| Partial | First page only |
Image Display Features
- Inline image preview in terminal
- Click to open in default app
- Cmd+click to copy to clipboard
- Right-click for context menu
- Automatic size adjustment
it2dl - Download Utility
# Basic download
it2dl https://example.com/file.pdf
# Specify destination
it2dl https://example.com/image.jpg ~/Downloads/
# Download with custom name
it2dl --name custom.jpg https://example.com/original.jpg
Password Manager Integration
iTerm2 can auto-fill passwords from macOS Keychain:
- Profile Settings โ Advanced โ Password Manager
- Enable “Password Manager” option
- Use keyboard shortcut to fill passwords
- Supports SSH key passphrases
Instant Replay
Access with: โโ (press Command twice)
- Rewind terminal history without scrollback limit
- Typical limit: last 100MB of data
- Navigate with arrow keys
- Disable with: Preferences โ Advanced โ Instant Replay disabled
Smart Selection
Right-click to select intelligently:
- Email addresses
- URLs
- IP addresses
- File paths
- Custom regex patterns
Define custom patterns in Preferences โ Profiles โ Advanced โ Smart Selection Rules.
Semantic History
Cmd+click to open files referenced in terminal:
- Application configuration via Cmd+click
- Custom opener selection available
- Supports relative and absolute paths
- Protocol handler integration (ssh://, ftp://)
Status Bar
Display terminal information persistently:
- Add components: View โ Toggle Status Bar
- Available indicators: hostname, git status, time, battery
- Customizable per profile
- Light/dark mode aware
Customize keyboard shortcuts for increased productivity.
Access Key Mappings
Profile Settings โ Keys โ Key Mappings
Common Key Mapping Examples
| Key Combo | Action | Hex Code |
|---|---|---|
| โโซ | Delete line | 0x15 |
| โโ | Move to line start | 0x01 |
| โโ | Move to line end | 0x05 |
| โฅโ | Move word back | 0x1b 0x62 |
| โฅโ | Move word forward | 0x1b 0x66 |
Hex Code Reference
0x01 = Ctrl+A (Home)
0x05 = Ctrl+E (End)
0x08 = Ctrl+H (Backspace)
0x15 = Ctrl+U (Clear line)
0x17 = Ctrl+W (Delete word)
0x1b = Escape prefix
Custom Mapping Example
Map โฅโซ to delete word backward:
- Key: โฅโซ
- Action: Send Hex Code
- Code:
0x17(Ctrl+W)
Vim Mode Key Mappings
For vim-style navigation:
| Vim Key | Map To | Hex/Text |
|---|---|---|
| jk | Escape | Literal String |
| โh | Left | Left Arrow |
| โj | Down | Down Arrow |
| โk | Up | Up Arrow |
| โl | Right | Right Arrow |
Badges and Titles
Set dynamic window titles in shell config:
# In ~/.zshrc
function set_title() {
print -Pn "\e]2;$1\a"
}
# Usage
set_title "Development Server"
Arrangements
Save window layouts for quick restoration:
- Arrange windows and panes as desired
- Window โ Save Window Arrangement
- Restore: Window โ Restore Arrangement
Buried Sessions
Hide background sessions without closing:
- Right-click session
- “Bury Session”
- Access via Window menu when needed
- Useful for long-running processes
Status Bar Customization
Add useful indicators to status bar:
- Hostname display
- Git branch/status
- Current time
- Battery percentage
- User-defined components via escape sequences
Command Palette
Quick access to iTerm2 functions:
- Press: โโงA
- Search for commands
- Recent commands prioritized
- Fully customizable
Search Enhancement
Advanced find features:
- Find in pane history: โF
- Regex pattern support
- Case-sensitive toggle
- Highlight all matches
- Jump to find results with Enter
Session Logging
Enable session recording for auditing:
# Enable logging
script ~/session-$(date +%s).log
# All terminal activity recorded to file
# Exit to close logging
exit
Color Schemes
Apply Catppuccin theme:
- Download theme files from catppuccin/iterm2
- Preferences โ Profiles โ Colors
- Color Presets โ Import
- Select Catppuccin Mocha
- Apply to profiles
Cursor Customization
Profile Settings โ Appearance โ Cursor:
- Block (default)
- Underline
- Vertical Bar
- Blinking toggle
- Color customization per profile