Skip to content
These pages follow main: some of what they describe is newer than 0.10.1, the latest release.

tmux.conf, starter

The file as it ships, docs/tmux.conf.starter.example.

Terminal window
# tmux-companion: a tmux.conf to start from
#
# Three example files ship, and this is the one to copy first:
#
# tmux.conf.starter.example this: the bar and the eight bindings worth
# having on day one, nothing else
# tmux.conf.example the bar alone, as one laptop runs it, with the
# measurements behind each line
# tmux.conf.full.example every feature on, with what each one costs
#
# Every line here is optional and every key is yours to move. The binary binds
# nothing on its own.
#
# ── Install order ───────────────────────────────────────────────────────────
#
# Binary first, then this file. The bar calls `tmux-companion status-right`,
# and against a binary without it the right-hand side is blank.
#
# ./scripts/install.sh # or: cargo build --release && sudo install ...
# tmux-companion doctor # can it see tmux, which config, which font
# tmux source-file ~/.config/tmux/tmux.conf
#
# After an upgrade: `tmux-companion restart`. The daemon is one long-lived
# process, and a new binary on disk changes nothing until it is restarted.
# ── The bar ─────────────────────────────────────────────────────────────────
#
# status-style is not optional: the segments draw against colour233 and
# tmux's default green shows through everywhere they do not reach without it.
set -g status-interval 1
set -g status-style bg=colour233,fg=colour251
# The host colour, set once: another machine's name is drawn in it on the bar
# (the ssh hostname, the `@vm` of a mirror session) and in the session
# switcher's rows, so a host looks the same wherever it is drawn.
set -g @tc-host-fg colour203
set -g @tc-host-bg colour233
# A copy made inside a mirror session is the host's tmux sending it here as
# OSC 52, and tmux's default, `external`, drops what a program in a pane
# sends, so it never reaches your terminal's clipboard. `on` lets any program
# in a pane set the clipboard, never read it, which is what a mirror needs.
set -s set-clipboard on
set -g status-left "#[fg=colour251,bg=colour236] #{?@tc-host,#{@tc-remote}#[fg=#{@tc-host-fg}#,bg=#{@tc-host-bg}]@#{@tc-host} 󰣀,#S} #[fg=colour240,bg=colour233] %H:%M:%S "
set -g status-left-length 80
set -g status-right-length 150
# One `#()` for the whole right side: git status, bandwidth and battery,
# computed together in the daemon. Do not split it into three; tmux spawns a
# process per `#()` per second per attached client, and that spawn is the
# whole cost of the bar.
# The daemon sees @tc-right here and, under `[bar] mode = "auto"` (the
# default), sets it in each attached session once a second for tmux to expand
# without starting anything, with a heartbeat in @tc-alive every 10 seconds.
# While the value is unset or the heartbeat is more than 30 seconds old (call
# mode, a daemon that stopped, or one that crashed) the line runs the call,
# which also starts a daemon, so a crash costs the bar 30 seconds at most. Push is the cheaper of the two by a call's cost
# per attached client per second; docs/BENCHMARKS.md has the numbers.
# After a switch the bar follows in tens of ms in either mode, push the sooner.
# In a mirror session (`api@vm`, a session on another machine opened from
# M-s) @tc-host is set and the right side is the host's segments, which the
# daemon sets as @tc-right in every bar mode: the call would show this
# machine's directory of the pane that runs the attach.
set -g status-right "#{?@tc-host,#{@tc-right},#{?#{&&:#{@tc-right},#{e|<:%s,#{e|+:#{@tc-alive},30}}},#{@tc-right},#(tmux-companion status-right --branch-max-len 40 #{pane_current_path})}}"
set -g window-status-format "#I:#W#{?window_flags,#{window_flags}, }"
set -g window-status-current-format "#I:#W#{?window_flags,#{window_flags}, }"
set -g window-status-separator " "
# ── Bindings ────────────────────────────────────────────────────────────────
#
# The `-N "companion: <group> ..."` note on each one is not decoration. `keys`
# (the searchable key list) and `cheatsheet` show the bindings that carry it
# and nothing else, and the word after `companion:` picks the cheat sheet box:
# pane, window, session, project, go, copy, open, search, config, help.
# A binding without the note works as a key and is invisible to both.
#
# Two of these sit in the root table (`-n`), so they fire without the prefix
# and take Alt-s and Alt-a away from every program in the pane. Drop the `-n`
# to put them behind the prefix instead.
# Which project. Live sessions first, then the directories zoxide (or
# `[project] dirs_source`) knows. Picking a directory builds its session from
# `[[layout]]` in config.toml, or a plain shell when there is none.
# `display-popup -B` (tmux 3.3 and later) leaves tmux's own border off, because
# the pickers draw theirs. tmux 3.2 has no -B, so there the %else line binds
# the same popup with both borders.
%if "#{>=:#{version},3.3}"
bind -N "companion: project switch session, or type to pick a project" -n M-s \
display-popup -B -E -w 80% -h 70% "tmux-companion switch sessions"
bind -N "companion: project switch session, oldest first" -n M-S \
display-popup -B -E -w 80% -h 70% "tmux-companion switch sessions --reverse"
%else
bind -N "companion: project switch session, or type to pick a project" -n M-s \
display-popup -E -w 80% -h 70% "tmux-companion switch sessions"
bind -N "companion: project switch session, oldest first" -n M-S \
display-popup -E -w 80% -h 70% "tmux-companion switch sessions --reverse"
%endif
# The project picker on its own, with every directory listed from the start:
# bind -n M-s display-popup -B -E -w 80% -h 70% "tmux-companion project"
# The windows of this session in the order you used them, Cmd-Tab's shape:
# one press goes back to the window you were on, a second within half a
# second opens a list, more presses move down it, and Enter goes. Esc
# stays. M-A walks the other way. [switcher] in config.toml has the timing,
# and first = "list" takes the last clock out.
bind -N "companion: project switch window, most recent first" -n M-a \
run-shell "tmux-companion switch windows '#{session_id}' --client '#{client_name}'"
bind -N "companion: project switch window, oldest first" -n M-A \
run-shell "tmux-companion switch windows '#{session_id}' --reverse --client '#{client_name}'"
# The order comes from these hooks, which only set options; `switch` sets
# them itself on its first press, and here the history starts with the server.
set-hook -g 'session-window-changed[73]' 'set -gF @tc_seq "#{e|+:#{@tc_seq},1}" ; set -wF @tc_win_used "#{@tc_seq}"'
set-hook -g 'client-session-changed[73]' 'set -gF @tc_seq "#{e|+:#{@tc_seq},1}" ; set -F @tc_ses_used "#{@tc_seq}"'
set-hook -g 'client-attached[73]' 'set -gF @tc_seq "#{e|+:#{@tc_seq},1}" ; set -F @tc_ses_used "#{@tc_seq}"'
# Every binding, searchable, and the same list as a cheat sheet.
%if "#{>=:#{version},3.3}"
bind -N "companion: help search every key binding" ? \
display-popup -B -E -w 80% -h 60% "tmux-companion keys"
%else
bind -N "companion: help search every key binding" ? \
display-popup -E -w 80% -h 60% "tmux-companion keys"
%endif
%if "#{>=:#{version},3.3}"
bind -N "companion: help cheat sheet of my bindings" C-c \
display-popup -B -E -w 90% -h 80% "tmux-companion cheatsheet"
%else
bind -N "companion: help cheat sheet of my bindings" C-c \
display-popup -E -w 90% -h 80% "tmux-companion cheatsheet"
%endif
# tmux's own prefix+c, with a say in the directory: the query starts on this
# pane's directory, so Enter is what prefix+c always did.
%if "#{>=:#{version},3.3}"
bind -N "companion: window new one here, or at any directory" c \
display-popup -B -E -w 65% -h 65% "tmux-companion new-window"
%else
bind -N "companion: window new one here, or at any directory" c \
display-popup -E -w 65% -h 65% "tmux-companion new-window"
%endif
# A command from shell history, run in a pane beside this one.
%if "#{>=:#{version},3.3}"
bind -N "companion: window run a command from history" e \
display-popup -B -E -w 70% -h 60% "tmux-companion run"
%else
bind -N "companion: window run a command from history" e \
display-popup -E -w 70% -h 60% "tmux-companion run"
%endif
# Every pane on the server, with what it runs and whether it has gone quiet;
# enter jumps there. `--agents` narrows it to the coding agents.
%if "#{>=:#{version},3.3}"
bind -N "companion: window jump to any pane" g \
display-popup -B -E -w 80% -h 70% "tmux-companion panes"
%else
bind -N "companion: window jump to any pane" g \
display-popup -E -w 80% -h 70% "tmux-companion panes"
%endif
# What the agents stopped to ask, oldest first; enter jumps to the one picked.
%if "#{>=:#{version},3.3}"
bind -N "companion: project the agents waiting on you" M-g \
display-popup -B -E -w 80% -h 70% "tmux-companion inbox"
%else
bind -N "companion: project the agents waiting on you" M-g \
display-popup -E -w 80% -h 70% "tmux-companion inbox"
%endif
# One screen of what needs you: the waiting agents, the health reasons, the
# idle sessions, the numbers. The same screen opens by itself on attach when
# there is news, through the client-attached hook below.
%if "#{>=:#{version},3.3}"
bind -N "companion: help what needs me" b \
display-popup -B -E -w 90% -h 75% "tmux-companion brief"
%else
bind -N "companion: help what needs me" b \
display-popup -E -w 90% -h 75% "tmux-companion brief"
%endif
# A click on the right side of the bar: the agent count opens the inbox, the
# health mark the brief. Needs `set -g mouse on`.
bind -T root MouseDown1StatusRight \
run-shell "tmux-companion click '#{mouse_status_range}'"
# What happened in each project today, newest first: what ran long, what the
# agents asked, what opened and closed.
%if "#{>=:#{version},3.3}"
bind -N "companion: help what happened today" J \
display-popup -B -E -w 80% -h 70% "tmux-companion journal"
%else
bind -N "companion: help what happened today" J \
display-popup -E -w 80% -h 70% "tmux-companion journal"
%endif
# Quiet hours from a prompt: `45m`, `2h`, or `off`. The health mark says
# `quiet` while it lasts.
bind -N "companion: config quiet hours, no nagging for a while" Q \
command-prompt -p "quiet for (45m, 2h, off):" "run-shell \"tmux-companion quiet %%\""
# Everything but this pane goes: a zoom with other panes open, the status bar
# with none.
bind -N "companion: pane zen, everything but this one goes" z \
run-shell "tmux-companion zen --pane '#{pane_id}'"
# Close this project cleanly, capturing its layout on the way out so it opens
# with the same windows next time.
bind -N "companion: session close this project cleanly" X \
confirm-before -p "close #{session_name}? (y/n)" "run-shell 'tmux-companion project close'"
# ── Later ───────────────────────────────────────────────────────────────────
#
# `tmux-companion theme init` writes the colour themes, `prefix C-t` picks one
# per project, and this hook paints a new session in its project's colour.
# With no themes on disk it does nothing and says nothing.
#
# bind -N "companion: config pick a colour theme" C-t \
# display-popup -E -w 70% -h 70% "tmux-companion theme pick"
# set-hook -g session-created "run-shell 'tmux-companion theme apply \"#{session_name}\" -t \"#{session_name}\"'"
#
# `[sessions] autosave` in config.toml snapshots every session on a timer, and
# `tmux-companion sessions resurrect` brings them back after a reboot.
# tmux.conf.full.example has the keys for that and everything else.