Iterm2

From G1Joshi/Agent-Skills · View interactive version

Iterm2 is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert iTerm2 terminal assistance covering split panes, profiles, trigger alerts, tmux integration, and shell integration. Use when optimizing macOS terminal productivity and keyboard navigation.

How to use this skill

Skill file

iTerm2

iTerm2 is an advanced terminal emulator for macOS, providing split panes, tmux integration, robust search, trigger automation, and customizable profiles.

When to Use

Quick Start

# Install iTerm2 Shell Integration for advanced prompt markers and status bar
curl -L https://iterm2.com/shell_integration/install_shell_integration.sh | bash

Useful Shortcuts:

Core Concepts

Shell Integration Installation & Benefits

Enabling semantic prompt navigation and status codes:

# Install iTerm2 shell integration for zsh or bash
curl -L https://iterm2.com/shell_integration/install_shell_integration.sh | zsh

# In ~/.zshrc or ~/.config/fish/config.fish
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

Features enabled:

tmux Integration via Control Mode (-CC)

Running remote persistent sessions as native local tabs:

# Connect to remote server and attach tmux session in control mode
ssh user@server.infra.internal -t "tmux -CC attach || tmux -CC new"

iTerm2 renders tmux windows as native tabs and panes with local mouse scrolling and clipboard integration.

Setting Dynamic Badges and Status Bars

Displaying active AWS profile or Git branch in the terminal background:

# Function to set iTerm2 badge dynamically
function iterm2_print_badge() {
  printf "\e]1337;SetBadgeFormat=%s\a" $(echo -n "$1" | base64)
}

# In prompt hook:
iterm2_print_badge "PROD | $(git branch --show-current)"

Common Patterns

Native Tmux Integration with iTerm2 Windows

Problem: Traditional tmux requires complex keyboard leader keys that conflict with terminal shortcuts.

Solution:

Attach tmux in native iTerm2 control mode:

# Attach session; iTerm2 converts tmux windows into native GUI tabs
tmux -CC attach -t dev-session

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| :------------------------------------------- | :--------------------------------------------------- | :----------------------------------------------------------------------------------------------------- |

| Broken symbols or question marks in prompt | Powerline/Nerd font missing in terminal profile. | Install a Nerd Font (e.g. JetBrainsMono Nerd Font) and select in iTerm2 Preferences > Profiles > Text. |

| Option key not working as Meta/Alt key | Option key sends special characters instead of Esc+. | In Preferences > Profiles > Keys, set Left Option Key to Esc+. |

| Terminal bell beep annoying | Audio bell enabled by default. | In Preferences > Profiles > Terminal, check Silence bell or flash screen. |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.