iterm2listed
Install: claude install-skill hsb3/dotfiles-agents
# iTerm2
Two things make iTerm2 unlike other terminals to automate: it keeps its **entire** configuration in
one plist that it rewrites from memory on quit, and its most valuable features are inert until
shell integration is installed. Most "my iTerm setting won't stick" problems are the first; most
"iTerm isn't better than Terminal.app" impressions are the second.
## The rule that governs every scripted change
**iTerm2 overwrites its preferences from memory when it quits.** Any `defaults write
com.googlecode.iterm2 …` made while iTerm2 is running is silently clobbered seconds later, when
the user quits. There is no error and no warning.
So: **quit iTerm2 before writing its preferences**, and guard every script that does so. Writing
prefs from a terminal running *inside* iTerm2 cannot work — run it from Terminal.app or another
emulator, or apply the change through the GUI.
Two traps sit inside that guard, both of which produce a check that silently reports the opposite
of the truth:
```bash
# WRONG on both counts.
if pgrep -xq iTerm2; then ...
```
- **`pgrep -x iTerm2` never matches.** pgrep compares against the full executable path
(`/Applications/iTerm.app/Contents/MacOS/iTerm2`), so exact-match never fires. Plain
`pgrep iTerm` is worse than useless: it matches the *helper* processes `iTermAI` and
`iTermServer-<version>`, so it returns true when the app itself is closed.
- **`ps … | grep -q` under `set -o pipefail` returns 141.** `grep -q` exits at the first ma