Skip to main content

Tmux Implementation

cli-expander supports tmux-native delivery for expanding triggers into any tmux pane, with a built-in fzf popup picker for trigger discovery.

Capabilities

FeatureCommand / BindingDescription
Inject into panece expand <trigger> --output tmuxInjects expansion into the current tmux pane
Target specific panece expand <trigger> --output tmux --target-pane <id>Injects into a specific pane (e.g. %1, $TMUX_PANE)
Auto-detect tmuxce expand <trigger> --output autoUses tmux inside tmux; stdout outside
Clipboard copyce expand <trigger> --output clipboardCopies expansion to system clipboard
Inject + Enterce expand <trigger> --output tmux --enterInjects and sends Enter
Prompt triggerprefix + eOpens a tmux prompt to type a trigger name
FZF popup pickerprefix + Ctrl+gOpens an fzf popup over all triggers, injects on selection

FZF Popup Picker

The popup picker (prefix+Ctrl+g) runs integrations/tmux/ce-tmux-picker.sh which:

  1. Reads the trigger database via ce list --json
  2. Converts JSON to tab-separated rows using python3 (handles commas in descriptions)
  3. Opens fzf in a tmux popup with preview pane
  4. On selection, expands the trigger into the original pane via ce expand --output tmux --target-pane
  5. Form triggers render inside the popup; completed output is injected into the original pane

Setup

# Build and install
cargo build --release
cp target/release/ce ~/.local/bin/ce
cp integrations/tmux/ce-tmux-picker.sh ~/.local/bin/ce-tmux-picker.sh

# Add to ~/.tmux.conf
run-shell /path/to/cli-expander/integrations/tmux/cli-expander.tmux

# Reload tmux
tmux source-file ~/.tmux.conf

Picker Options

The fzf picker uses tab-delimited data for reliable parsing:

--delimiter=$'\t' --with-nth=1,2
--preview='ce details {1} 2>/dev/null'
--preview-window=right:60%:wrap
--header='Enter: inject into selected pane | Esc: cancel'

Safety and Limits

  • Tmux output inserts text only by default; it does not press Enter unless --enter is set
  • Multiline tmux injection is rejected until paste-buffer support is implemented
  • The $|$ cursor marker is stripped in tmux mode (cursor positioning is shell-plugin-only)
  • Full-screen terminal apps must have their input area focused for injection to work
  • Shell plugin mode remains best for prompt-local expansion; tmux mode is best for cross-pane workflows and popup trigger selection

CLI Reference

# Inject into current pane
ce expand ":hello" --output tmux

# Inject into a specific pane
ce expand ":findx" --output tmux --target-pane %1

# Inject with enter
ce expand ":hello" --output tmux --enter

# Auto-detect: tmux if inside tmux, stdout otherwise
ce expand ":hello" --output auto

# Copy to clipboard
ce expand ":hello" --output clipboard