|
| 1 | +# 21. Tmux Pillbox-Styled Session Chooser |
| 2 | + |
| 3 | +Date: 2026-01-28 |
| 4 | + |
| 5 | +## Status |
| 6 | + |
| 7 | +Accepted |
| 8 | + |
| 9 | +## Context |
| 10 | + |
| 11 | +The tmux status bar uses a consistent pillbox visual style with Catppuccin Mocha colors—rounded separators, colored backgrounds, and semantic color coding (green for active, blue for info, etc.). The built-in session chooser (`prefix+s`, which invokes `choose-tree -Zs`) uses plain default formatting, creating visual inconsistency. |
| 12 | + |
| 13 | +Goals: |
| 14 | + |
| 15 | +1. Apply pillbox styling to the session chooser for visual consistency |
| 16 | +2. Add semantic color coding (green for attached sessions, blue for others) |
| 17 | +3. Display useful metadata (window count) in a compact format |
| 18 | + |
| 19 | +## Decision |
| 20 | + |
| 21 | +Customize the `choose-tree` format using the `-F` flag with pillbox styling that matches the status bar. |
| 22 | + |
| 23 | +### Implementation |
| 24 | + |
| 25 | +```tmux |
| 26 | +set -g @_icon_windows " " # nf-md-dock_window |
| 27 | +set -g @_chooser_format "\ |
| 28 | +#{?session_attached,#[fg=#a6e3a1],#[fg=#89b4fa]}\ |
| 29 | +#{@_pill_left}\ |
| 30 | +#{?session_attached,#[fg=#11111b]#[bg=#a6e3a1],#[fg=#11111b]#[bg=#89b4fa]} \ |
| 31 | +#{session_windows} #{@_icon_windows}\ |
| 32 | +#{?session_attached,#[fg=#a6e3a1],#[fg=#89b4fa]}#[bg=default]\ |
| 33 | +#{@_pill_right}#[default]" |
| 34 | + |
| 35 | +bind-key s choose-tree -Zs -F "#{E:@_chooser_format}" |
| 36 | +``` |
| 37 | + |
| 38 | +### Key Constraint Discovered |
| 39 | + |
| 40 | +The `choose-tree` command hardcodes a prefix before the custom format: |
| 41 | + |
| 42 | +``` |
| 43 | +(shortcut) indicator session-name: <custom format> |
| 44 | +``` |
| 45 | + |
| 46 | +The session name before the colon **cannot be removed, styled, or replaced**. The `-F` format only controls what appears after the colon. This limits alignment possibilities since session names vary in length. |
| 47 | + |
| 48 | +### Alternatives Considered |
| 49 | + |
| 50 | +1. **Include session path in format** |
| 51 | + |
| 52 | + - Tried: `#{s|$HOME|~|:session_path}` with padding/truncation |
| 53 | + - Rejected: Path often duplicates session name; varying session name lengths before the colon prevent clean alignment regardless of padding |
| 54 | + |
| 55 | +2. **Pad path to fixed width for alignment** |
| 56 | + |
| 57 | + - Tried: `#{p-40:#{=/38/...:path}}` (40-char left-aligned field with truncation) |
| 58 | + - Rejected: Pills align relative to path column, but the column itself shifts based on session name length—the part we can't control |
| 59 | + |
| 60 | +3. **Use fzf-based picker instead** |
| 61 | + |
| 62 | + - `sesh` already provides this on `prefix+T` with full format control |
| 63 | + - Rejected for `prefix+s`: Keep the built-in for quick access; fzf picker serves different use case (fuzzy search, zoxide integration) |
| 64 | + |
| 65 | +4. **Include activity/recency timestamp** |
| 66 | + - Available via `#{t:session_activity}` |
| 67 | + - Deferred: Adds clutter; may revisit if needed |
| 68 | + |
| 69 | +## Consequences |
| 70 | + |
| 71 | +### Positive |
| 72 | + |
| 73 | +- **Visual consistency**: Session chooser now matches status bar styling |
| 74 | +- **Semantic coloring**: Green pills for attached sessions provide instant visual scanning |
| 75 | +- **Compact metadata**: Window count visible at a glance with icon |
| 76 | +- **Preserves functionality**: Built-in choose-tree behavior unchanged; just styled |
| 77 | + |
| 78 | +### Negative |
| 79 | + |
| 80 | +- **Limited control**: Cannot style or remove the hardcoded session name prefix |
| 81 | +- **Alignment impossible**: Varying session name lengths cause pills to appear at different horizontal positions |
| 82 | +- **Nerd font dependency**: Requires nerd fonts for pill separators and window icon |
| 83 | + |
| 84 | +### Files |
| 85 | + |
| 86 | +- `home/.tmux.conf`: Format definition and keybinding |
0 commit comments