Skip to content

About

Mission Control-style tmux session switcher with live terminal previews

Resources

Stars

79 stars

Watchers

2 watching

Forks

Latest commit

 

History

70 Commits

Folders and files

Repository files navigation

tmux.expose

Mission Control-style tmux session switching from a fast terminal UI.

CI Crates.io License

Install  ·  Quickstart  ·  tmux Plugin  ·  Configuration


tmux.expose in action

Why tmux.expose

Switching tmux sessions with a list works, but it gives you names instead of context. tmux.expose shows every session as a live text thumbnail so you can jump to the right workspace visually.

  • See before switching. Browse sessions in a responsive grid with live pane previews.
  • Terminal-native. A small Rust TUI that runs inside your terminal or a tmux popup.
  • Color-aware previews. tmux ANSI colors are preserved in thumbnails.
  • Fast keyboard flow. Move with arrows or hjkl, switch with Enter, leave with q or Esc.
  • TPM-ready. Install it as a tmux plugin and launch with Alt+e.

Install

The shortest path is crates.io:

cargo install tmux-expose

tmux Plugin

Install with TPM:

set -g @plugin 'cesarferreira/tmux.expose'

Reload tmux config, then press prefix + I to install plugins.

The plugin binds Alt+e by default:

Alt+e

It opens:

tmux display-popup -w 100% -h 100% -E "tmux-expose"

With the default binding, press Alt+e again while tmux.expose is open to close it without switching.

Configuration

Customize the tmux plugin before the @plugin line:

set -g @tmux-expose-key 'E'
set -g @tmux-expose-key-table 'prefix'
set -g @tmux-expose-width '100%'
set -g @tmux-expose-height '100%'
set -g @tmux-expose-anchor 'center'
set -g @tmux-expose-style 'bg=colour234'
set -g @tmux-expose-border-style 'fg=colour245'
set -g @tmux-expose-selected-color 'yellow'
set -g @tmux-expose-attached-color 'green'
set -g @tmux-expose-inactive-color 'white'
set -g @tmux-expose-vim-keys 'on'
set -g @tmux-expose-command 'tmux-expose --columns 2'

set -g @plugin 'cesarferreira/tmux.expose'

@tmux-expose-anchor accepts center, top, bottom, left, or right. For example, use set -g @tmux-expose-anchor 'bottom' with set -g @tmux-expose-height '50%' to show tmux.expose in the bottom half of the screen.

@tmux-expose-style maps to display-popup -s, and @tmux-expose-border-style maps to display-popup -S.

Card colors

Each session card is highlighted based on its state. Recolor any of them to match your theme:

Option Highlights Default
@tmux-expose-selected-color The card under the cursor (title + border) yellow
@tmux-expose-attached-color The session you are currently attached to (title + border) green
@tmux-expose-inactive-color Every other card (title only; the border stays dimmed) white

Values accept a color name (yellow, cyan, …), a 256-color index (colour208 or 208), or a hex value (#ff8700). Omit an option to keep its default.

For example, a Dracula-flavored setup:

set -g @tmux-expose-selected-color '#bd93f9'
set -g @tmux-expose-attached-color '#50fa7b'
set -g @tmux-expose-inactive-color '#6272a4'

The same colors are also available as CLI flags when running the binary directly:

tmux-expose --selected-color '#bd93f9' --attached-color '#50fa7b' --inactive-color '#6272a4'

Agent status (Claude Code, and other agents)

If you run coding agents inside tmux panes, tmux.expose can sort and badge sessions by whether an agent in them is waiting on you — instead of showing every session in the same flat, alphabetical order regardless of what's actually going on inside it.

This works on any agent that can run a shell command on state changes. No config is required to make tmux.expose display it — the moment something writes the tmux pane options below, the grid picks it up on its next refresh:

tmux pane option Meaning
@agent_status working, waiting, or attention
@agent_status_since Unix timestamp of when that status started

working means the agent is actively running. waiting means its turn just ended and it's idle on you. attention means it's blocked on something stronger, like a permission prompt. A session's card takes the worst status across all of its panes (attention > waiting > working), so a multi-agent session never hides a stuck pane behind a busy one — and by default, sessions with a waiting or blocked agent sort to the top of the grid, oldest-waiting first, and the cursor starts on the top one instead of your current session.

A single tracked pane gets a plain label on the card's bottom border:

⏳ awaiting reply

A session with more than one agent pane always spells out its worst status in words — that's the one setting the card's color and sort position, so it's the one thing you need to read at a glance — and shows the rest as compact counts:

‼ needs you · ⏳2 · ⚙1

(Words instead of a bare glyph+count everywhere is deliberate: emoji rendering varies by terminal font, so a symbol that fails to render is silent for the status that matters most.)

The binary ships a one-shot helper for setting these, so nothing but tmux-expose itself needs to be on PATH:

tmux-expose agent-status working    # agent just started a turn
tmux-expose agent-status waiting    # agent's turn ended, idle on you
tmux-expose agent-status attention  # agent is blocked (e.g. needs a permission)
tmux-expose agent-status clear      # agent/session is done — remove the marker

It reads $TMUX_PANE to know which pane to tag and no-ops outside tmux, so it's safe to wire into any hook without guarding it yourself.

Claude Code setup

Add this to ~/.claude/settings.json (global — applies to every project) or a project's own .claude/settings.json:

{
  "hooks": {
    "UserPromptSubmit": [
      { "hooks": [{ "type": "command", "command": "tmux-expose agent-status working" }] }
    ],
    "Stop": [
      { "hooks": [{ "type": "command", "command": "tmux-expose agent-status waiting" }] }
    ],
    "PostToolUse": [
      {
        "matcher": "",
        "hooks": [{ "type": "command", "command": "tmux-expose agent-status working" }]
      }
    ],
    "Notification": [
      {
        "matcher": "permission_prompt",
        "hooks": [{ "type": "command", "command": "tmux-expose agent-status attention" }]
      }
    ],
    "SessionEnd": [
      {
        "matcher": "",
        "hooks": [{ "type": "command", "command": "tmux-expose agent-status clear" }]
      }
    ]
  }
}

If you already have a hooks block, merge these events into it rather than replacing it. Restart (or start a new) Claude Code session afterwards — hooks are read once at session start, so a session already running won't pick up an edit to settings.json.

Other agents work the same way: run tmux-expose agent-status <word> from whatever hook, lifecycle script, or wrapper that agent exposes.

Card colors and sort order

Sensible defaults ship with the binary, so none of this is required — only set it to match your theme or to opt out of the sort:

Option Highlights Default
@tmux-expose-attention-color A session with a pane blocked on you #ff5555
@tmux-expose-waiting-color A session where an agent's turn just ended #ffb86c
@tmux-expose-working-color A session with an agent still running #8be9fd
@tmux-expose-agent-sort Set to off to keep tmux's own session order instead on
set -g @tmux-expose-attention-color '#ff5555'
set -g @tmux-expose-waiting-color '#ffb86c'
set -g @tmux-expose-working-color '#8be9fd'
set -g @tmux-expose-agent-sort 'on'

Also available as CLI flags: --attention-color, --waiting-color, --working-color, --no-agent-sort.

Jump to the next agent

To triage without opening the picker, bind a key to tmux-expose next. Each press switches to the next session whose agent is blocked on or waiting for you, in the same priority order as the grid, and wraps around, so repeated presses visit every one of them instead of bouncing between the two oldest. If nothing else needs you, it shows a brief message and stays put.

Option Description Default
@tmux-expose-next-key Key that jumps to the next agent session unbound
@tmux-expose-next-key-table Key table for that key prefix
@tmux-expose-binary Executable next runs, if different from the picker derived from @tmux-expose-command
set -g @tmux-expose-next-key 'N'   # <prefix> N

next normally reuses the executable named in @tmux-expose-command. If that value quotes a path containing a space (e.g. '/opt/my tools/tmux-expose' --columns 2), set @tmux-expose-binary explicitly rather than relying on it being parsed out:

set -g @tmux-expose-binary '/opt/my tools/tmux-expose'

From a shell inside tmux you can also run tmux-expose next directly.

Vim navigation

Set @tmux-expose-vim-keys 'on' (or run tmux-expose --vim) to switch the picker to modal vim keys. It is off by default, leaving the standard type-to-filter behavior unchanged.

When enabled, the picker starts in normal mode:

Key Action
h j k l (or arrows) Move the selection
/ Enter search mode
Enter Switch to the selected session
q / Esc Quit

Pressing / enters search mode, where typing fuzzy-filters as usual (so h/j/k/l become text again). Esc commits whatever you typed as a filter and drops back into normal mode — Telescope-style — so hjkl browses the filtered results instead of typing into them; Enter switches straight from either mode. Press / again to start a fresh search, or Esc a second time (from normal mode, with a filter still applied) to clear it. Escaping an empty query cancels instead of applying an empty filter.

Note: @tmux-expose-vim-keys works by appending --vim to @tmux-expose-command (which defaults to tmux-expose). If you point @tmux-expose-command at a custom wrapper script, make sure it accepts --vim — or set the flag there yourself instead. The @tmux-expose-*-color options behave the same way.

Custom Example

This configuration binds tmux.expose to prefix + s and opens it as a bottom-anchored popup using 60% of the screen height:

set -g @tmux-expose-key 's'
set -g @tmux-expose-key-table 'prefix'
set -g @tmux-expose-width '100%'
set -g @tmux-expose-height '60%'
set -g @tmux-expose-anchor 'bottom'
set -g @tmux-expose-style 'bg=colour234'
set -g @tmux-expose-border-style 'fg=colour245'

set -g @plugin 'cesarferreira/tmux.expose'

Custom tmux.expose popup example

It produces a popup equivalent to:

tmux display-popup -w 100% -h 60% -y '#{popup_pane_bottom}' -s 'bg=colour234' -S 'fg=colour245' -e TMUX_EXPOSE_TOGGLE_KEY=s -E "tmux-expose"

Use a direct binding if you do not use TPM:

bind-key -T root M-e display-popup -w 100% -h 100% -e TMUX_EXPOSE_TOGGLE_KEY=M-e -E "tmux-expose"

Quickstart

Run the UI directly inside tmux:

tmux-expose

Or open it in a tmux popup:

tmux display-popup -w 100% -h 100% -E "tmux-expose"

By default, thumbnails are sized into a balanced grid that fits all sessions on screen. Override the layout when you want larger previews or a fixed grid:

tmux-expose --thumbnail-width 48
tmux-expose --columns 2
tmux-expose --thumbnail-width 48 --columns 2

Refresh interval defaults to 500ms:

tmux-expose --refresh-interval 500

Recolor the card highlights (names, 256-color indices, or hex values are accepted):

tmux-expose --selected-color cyan --attached-color green --inactive-color white

Controls

Key Action
Type Filter sessions by fuzzy name
Arrow keys Move selection
Mouse click Switch to clicked session
Backspace Edit search query
Ctrl-W Delete the previous word of the search query
Ctrl-U Clear the search query (keeps searching)
Esc while searching Clear search
Enter Switch to selected session
Esc / Ctrl-C Quit without switching

Prefer vim keys? See Vim navigation for an opt-in hjkl mode.

macOS Gesture Integration

Use BetterTouchTool, Hammerspoon, Raycast, or another automation tool to trigger:

tmux display-popup -w 100% -h 100% -E "tmux-expose"

The app itself is terminal-only and does not depend on macOS-specific APIs.

Development

Before opening a PR, run:

make check

License

MIT © Cesar Ferreira

About

Mission Control-style tmux session switcher with live terminal previews

Resources

Stars

79 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages