Expose Claude Code session metadata as iTerm2 user vars (tab/window title, badge).
A Claude Code plugin that exposes session info as iTerm2 user variables. The variables work anywhere iTerm2 accepts an interpolated string: tab subtitle, window title, badge, and status bar. Vertical tabs benefit the most, since the subtitle line is usually wasted space.

The screenshot above shows three tabs, each with a custom subtitle built from \(user.claude_subtitle), and the same information reused in the status bar.
jq, base64, git, ps (all default on macOS)/plugin marketplace add sherifabdlnaby/claude-iterm-vars
/plugin install iterm-vars@sherifabdlnaby
/reload-plugins
In iTerm2, open Preferences, Profiles, General. The Title row has three fields (Title, Subtitle, Icon) that accept interpolated strings. You can also reference the same variables from the status bar (Preferences, Profiles, Session, Configure Status Bar) or from the badge (Preferences, Profiles, General, Badge).
Easiest starting point, paste into Subtitle:
\(user.claude_subtitle)
That gives you ✳ mode | state | repo, with segments dropping cleanly when empty.
For more control, use the raw variables listed below and compose your own format.
| Name | Meaning | Updated |
|---|---|---|
claude_session | Last 6 chars of the session UUID | Every event |
claude_repo | Git repo name, or cwd basename | Every event |
claude_mode | Permission mode (auto, plan, default) | Every event |
claude_state | idle, thinking, tool(<name>), waiting | Every event |
claude_title | First user message or Claude's own session title | First prompt, or resume |
claude_last_usr_msg | Last user message, truncated | UserPromptSubmit |
claude_last_agent_msg | Last assistant reply, truncated | Stop |
claude_subtitle | Composed ✳ mode | state | repo with empty segments dropped | Every event |
claude_title prefers Claude Code's custom-title from the transcript when present, and otherwise captures the first user message.
iTerm2's title-field expression grammar doesn't support string literals, comparisons, ternary, or + concat. That means you can't do conditionals inline. Use claude_subtitle for the common case, or keep in mind that empty raw variables leave their separators behind.
Basic:
\(user.claude_subtitle)
Raw composition (watch for orphan separators when values are empty):
\(user.claude_repo): \(user.claude_last_usr_msg)
Each hook event runs hooks/dispatch.sh. The script reads the event payload on stdin, walks parent PIDs to find the controlling tty, and writes iTerm2 OSC 1337 SetUserVar escapes to it. iTerm2 stores the variables and expands them wherever you reference them.
No LLM calls. Runs in well under 50ms per event.
\(user.claude_*) somewhere, and that /reload-plugins shows iterm-vars in the summary.rm ~/.claude/plugins/data/iterm-vars-sherifabdlnaby/titles/*
set -g allow-passthrough on to your tmux config. Untested beyond that.MIT.
Matches all tools
Hooks run on every tool call, not just specific ones
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
npx claudepluginhub sherifabdlnaby/claude-iterm-vars --plugin iterm-varsMCP server that saves 98% of your context window with session continuity. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and automatic state restore across compactions.
Complete AI coding workflow system. Self-correcting memory + persistent FTS5-indexed research wikis + auto-research loop + multi-LLM council on a single SQLite store. 33 skills, 8 agents, 22 commands, 37 hook scripts across 24 events. Cross-agent via SkillKit.
Open-source, local-first Claude Code plugin for token reduction, context compression, and cost optimization using hybrid RAG retrieval (BM25 + vector search), reranking, AST-aware chunking, and compact context packets.