| Date | Summary of Changes |
|---|---|
| 2026-02-09 | Keep Codex pane focused after resize and refine mouse-scroll defaults |
| 2026-02-09 | Update session attach defaults and scrollback-related configuration docs |
Real-time statusline HUD for OpenAI Codex CLI.
Note: This is a wrapper tool that runs alongside Codex CLI, inspired by claude-hud for Claude Code.
# Clone and install
git clone https://github.com/fwyc0573/codex-hud.git
cd codex-hud
./install.sh
# Close and reopen your terminal or use `source ~/.bashrc` or `source ~/.zshrc` to
# refresh your shell environment.
# Now just type 'codex' - HUD appears automatically!That's it! After installation, typing codex will automatically launch with the HUD display.
- Model Display: Shows current model from
config.toml - Git Status: Branch, dirty indicator, ahead/behind, and change counts
- Project Info: Project name and working directory
- Session Timer: Time since session started
- Config/Mode Signals:
.codexconfig count, work mode, and extensions (MCP servers) - Instruction Signals: Counts for AGENTS.md, INSTRUCTIONS.md, and
.codex/rules - Approval Policy + Sandbox: Displays approval policy and sandbox mode when configured
- Token + Context Usage: Real-time token and context window usage
- Reads
token_countandturn_startedevents from rollout files - Uses
last_token_usagewith baseline token reservation - Shows
/compactcount fromcontext_compactedevents
- Reads
- Tool Activity Tracking: Monitors tool invocations
- Shows recent tool calls count
- Displays total tool calls in session
- Parses
function_callentries from rollout logs
- File Watching: Event-driven updates using chokidar
- Watches config.toml for changes
- Watches active session rollout files
- Session Auto-Detection: Automatically finds active Codex sessions
- Filters by session CWD and searches recent sessions (default: 30 days)
- Prioritizes recently modified sessions
- Automatic tmux Installation: Installs tmux if not present
- Shell Alias Integration:
codexandcodex-resumelaunch with HUD - Per-Launch Sessions: Each run creates a new tmux session and auto-cleans on exit
- Configurable HUD Position: Top or bottom (environment variable)
- One-Command Install/Uninstall: Simple setup and removal
- HUD Mode Toggle: Switch between single-session details and multi-session overview
- Node.js 18+
- OpenAI Codex CLI installed and in PATH
- tmux (auto-installed if missing)
- Codex home available at
CODEX_HOME,~/.codex, or~/.codex_home(with asessions/directory orCODEX_SESSIONS_PATH)
# Run the installer
./install.shThe installer will:
- Install Node.js dependencies
- Build the TypeScript project
- Add shell aliases (
codex,codex-resume) to~/.bashrcand~/.zshrc(with backups) - Prompt to install tmux if not present
After installation, refresh your shell environment so the aliases take effect:
# Bash
source ~/.bashrc
# Zsh
source ~/.zshrcAlternatively, close and reopen your terminal.
# Clone or download this repository
cd codex-hud
# Install dependencies
npm install
# Build the project
npm run build
# Make the wrapper executable
chmod +x bin/codex-hud
# Add alias to your shell config (~/.bashrc or ~/.zshrc)
echo "alias codex='/path/to/codex-hud/bin/codex-hud'" >> ~/.bashrc
echo "alias codex-resume='/path/to/codex-hud/bin/codex-hud resume'" >> ~/.bashrc
source ~/.bashrc./uninstall.shThis will:
- Remove the codex-hud aliases from common shell rc files
- Kill any running codex-hud sessions and HUD panes
- Restore backed-up aliases if available
After uninstalling, refresh your shell environment so the changes take effect:
# Bash
source ~/.bashrc
# Zsh
source ~/.zshrcAlternatively, close and reopen your terminal.
- Linux
- macOS (Apple Silicon)
- Windows (testing pending)
- macOS (Intel Silicon) (testing pending)
After installation, just use codex as you normally would:
# Basic usage - HUD appears automatically
codex
# With arguments (passed to codex)
codex --model gpt-5
# With initial prompt
codex "help me debug this"
# Resume (passes through to codex CLI)
codex-resume# Kill existing session for current directory
codex-hud --kill
# List all codex-hud sessions
codex-hud --list
# Show help
codex-hud --help
# Intentionally attach to an existing session
codex-hud --attach
# Always create a new session for this launch
codex-hud --new-session
# Run environment diagnostics
codex-hud --self-checkcodex-hud enables tmux mouse mode by default so trackpad/mouse wheel scrolling works in the Codex pane. Resize hooks also reselect the main Codex pane to keep input focus stable. By default, it sets alternate-screen to off so history remains scrollable. Set CODEX_HUD_MOUSE=0 only if you prefer tmux mouse mode disabled.
| Variable | Description | Default |
|---|---|---|
CODEX_HUD_POSITION |
HUD pane position: bottom, top |
bottom |
CODEX_HUD_HEIGHT |
HUD pane height in lines | 1/6 of terminal height (min 5) |
CODEX_HUD_HEIGHT_AUTO |
Auto-adjust HUD height based on pane width | 0 |
CODEX_HUD_HEIGHT_MIN |
Minimum HUD height in auto mode | CODEX_HUD_HEIGHT |
CODEX_HUD_HEIGHT_MAX |
Maximum HUD height in auto mode | 12 |
CODEX_HUD_AUTO_ATTACH |
Auto-attach to the latest existing session in the same directory | 0 |
CODEX_HUD_NO_ATTACH |
Deprecated: force a new session (overrides auto attach) | (unset) |
CODEX_HUD_ALTERNATE_SCREEN |
Set tmux alternate-screen for the codex pane (0/1) |
0 |
CODEX_HUD_MOUSE |
Enable tmux mouse mode for wheel/trackpad scrolling (0/1) |
1 |
CODEX_HUD_CLEAR_SCROLLBACK |
Clear tmux scrollback on HUD first render | 0 |
CODEX_HUD_CWD |
Override working directory used for HUD context/session matching | (unset; wrapper sets) |
| Variable | Description | Default |
|---|---|---|
CODEX_HOME |
Codex home directory (config + sessions) | ~/.codex or ~/.codex_home |
CODEX_SESSIONS_PATH |
Override sessions directory | (unset) |
Example:
# Put HUD on top
CODEX_HUD_POSITION=top codex
# Taller HUD
CODEX_HUD_HEIGHT=5 codexNote: HUD height is clamped to the available terminal size.
The wrapper creates a tmux session with:
- Main pane: Codex CLI
- HUD pane: Status lines (expanded layout shows multiple lines; compact layout shows one line)
[gpt-5.2-codex] █████░░░░ 45% │ my-project git:(main ●) │ ⏱️ 12m
1 configs | mode: dev | 3 extensions | 2 AGENTS.md | Approval: on-req | Sandbox: ws-write
Tokens: 50.2K (in: 35.0K, cache: 5.0K, out: 15.2K) | Ctx: ████░░░░ 45% (50.2K/128K) ↻2
Dir: ~/my-project | Session: abc12345 | CLI: 0.4.2 | Provider: openai
◐ Edit: file.ts | ✓ Read ×3
[model-name]- Current model█████░░░░ 45%- Context usage bar (from session token data)project-name- Current directory namegit:(branch ●)- Git branch + dirty indicator (if in repo)⏱️ duration- Session duration
N configs-.codexconfig file countmode: dev/prod- Work mode from environmentN extensions- Enabled MCP serversN AGENTS.md/N INSTRUCTIONS.md/N rules- Instruction signalsApproval: policy- Approval policySandbox: mode- Sandbox mode (if configured)
Tokens: N- Total tokens (with input/cache/output breakdown when available)Ctx: ███░░ 45% (used/total)- Context usage bar and counts↻N- Compact count when/compactevents occur
Dir: ~/path- Working directory (truncated)Session: abc12345- Session ID (short)CLI: x.y.z/Provider: openai- Optional session metadata
◐ Edit: file.ts- Running tool call✓ Read ×3- Recent tool calls grouped with counts- Plan progress lines when available
When the HUD height is smaller than the number of available lines, extra lines are trimmed with a …N more lines hidden indicator.
Codex HUD supports two display modes:
- Single Session Mode (default)
- Shows detailed info for the current Codex session.
- Multi Session Overview Mode
- Shows only active sessions (tool calls or generation activity).
- Each line shows Context usage + Session ID.
- Prefix + H (tmux) toggles between modes.
- When focused on the HUD pane, you can also press Ctrl+T.
The HUD reads configuration from CODEX_HOME/config.toml (defaults to ~/.codex/config.toml, with fallback to ~/.codex_home/config.toml).
# Model configuration
model = "gpt-5.2-codex"
model_provider = "openai"
# Approval policy
approval_policy = "on-request"
# Sandbox mode
sandbox_mode = "workspace-write"
# MCP servers
[mcp_servers]
[mcp_servers.my-server]
command = ["node", "server.js"]
enabled = trueToken data is extracted from Codex session rollout files:
- Location:
CODEX_SESSIONS_PATHor${CODEX_HOME:-~/.codex}/sessions/YYYY/MM/DD/rollout-*.jsonl - Format: JSONL with
event_msgentries containingtoken_count,turn_started, andcontext_compacted - Fields:
total_token_usage,last_token_usage,model_context_window,cached_input_tokens
Tool invocations are tracked from rollout files:
- Type:
response_itemwithfunction_callandfunction_call_output - Tracked: Tool name, duration, success/failure status
- Display: Recent calls count and total session calls
codex-hud/
├── bin/
│ └── codex-hud # Bash wrapper (creates tmux session)
├── src/
│ ├── index.ts # Main entry point
│ ├── test-render.ts # Render test harness
│ ├── types.ts # Type definitions
│ ├── utils/
│ │ └── codex-path.ts # Resolve CODEX_HOME + sessions path
│ ├── collectors/
│ │ ├── codex-config.ts # Parse config.toml
│ │ ├── file-watcher.ts # chokidar-based watchers
│ │ ├── git.ts # Git status collection
│ │ ├── project.ts # Project info collection
│ │ ├── rollout.ts # Parse session rollout files
│ │ └── session-finder.ts # Find active sessions
│ └── render/
│ ├── colors.ts # ANSI color utilities
│ ├── header.ts # Status line rendering
│ ├── index.ts # Main renderer
│ └── lines/ # Line renderers
│ ├── activity-line.ts
│ ├── environment-line.ts
│ ├── identity-line.ts
│ ├── project-line.ts
│ ├── session-line.ts
│ └── usage-line.ts
├── dist/ # Compiled JavaScript
├── package.json
└── tsconfig.json
# Install dependencies
npm install
# Build
npm run build
# Watch mode (rebuild on changes)
npm run dev
# Run HUD directly (for testing)
node dist/index.js- Token usage accuracy: Depends on Codex session rollout format
- Requires tmux: The split-pane display needs tmux
- Wrapper launch required: Use
codex-hud(or thecodex/codex-resumealiases) to see the HUD - Session detection delay: Up to 5 seconds to detect new sessions
- Added token usage display with progress bar
- Added tool activity tracking
- Added session auto-detection
- Added file watching with chokidar
- Added rollout file parsing
- Initial release
- Basic model, git, project info display
- MCP servers and approval policy display
- tmux wrapper script
MIT
Inspired by claude-hud by Jarrod Watts.
Built for use with OpenAI Codex CLI.
