Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@ Invalid values behave like `auto`. For example, `session` keeps the existing
prefix behavior by default while its leading is visible (red leading when
`client_prefix` is active), but `@themux_session_state_target text` moves that red
active accent to the text and `@themux_session_leading_show off` lets `auto` move
it there for you.
it there for you. Some modules ship their own per-module default: `git` sets
`@themux_git_state_target` to `both` so a dirty work tree warms every slot
whose variant displays the accent, and `cpu`/`ram` do the same for their live
threshold colour (see below).

The `cpu`/`ram` threshold modules carry tmux-cpu's live level colour
`#{<name>_bg_color}` as their accent — green at rest, warming yellow → red as the
Expand Down
7 changes: 6 additions & 1 deletion docs/reference/status-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ switches the accent from `@themux_git_color` to `@themux_git_active_color`
through the module active state, so the pill warms natively under any variant
and always agrees with the text. Divergence does not escalate: the probe
checks the work tree only, so a diverged-but-clean tree keeps the resting
accent.
accent. The escalation targets both slots by default
(`@themux_git_state_target` defaults to `both`), so every slot whose variant
displays the accent warms — with a `solid` text the whole pill turns, while
the stock `soft` text has no accent channel and keeps its neutral block. Set
the target to `leading` or `text` to warm one slot only, or `off` to never
escalate — see [state target](./configuration.md#status-modules).

```sh
set -g @themux_git_color "#{E:@thm_role_accent}" # resting (clean)
Expand Down
10 changes: 10 additions & 0 deletions modules/git.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ set -ogq "@themux_${MODULE_NAME}_active_color" "#{E:@thm_role_notice}"
set -gq "@_tmx_${MODULE_NAME}_dirty" '#("#{E:@_tmx_git_script}" --dirty "#{pane_current_path}")'
set -ogq "@themux_${MODULE_NAME}_active_when" "#{E:@_tmx_${MODULE_NAME}_dirty}"

# The dirty escalation targets both slots: state_target defaults to both so
# every slot whose variant displays the accent warms on a dirty tree. Under
# `auto` an accent-bearing text (solid/subtle/naked) kept the resting accent
# next to an escalated icon — a two-tone pill. The stock soft text has no
# accent channel, so there the renderer still collapses the text switch and
# nothing changes. Same per-module default pattern as cpu/ram in
# utils/metric_module.conf; @themux_git_state_target stays a user option to
# move or suppress the escalation.
set -ogq "@themux_${MODULE_NAME}_state_target" "both"

# Only render inside a git work tree (a cheap rev-parse, evaluated per refresh).
set -gq "@_tmx_${MODULE_NAME}_in_repo" '#(git -C "#{pane_current_path}" rev-parse --is-inside-work-tree 2>/dev/null)'
set -gq "@themux_${MODULE_NAME}_when" "#{E:@_tmx_${MODULE_NAME}_in_repo}"
Expand Down
25 changes: 21 additions & 4 deletions tests/git_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,27 @@ tmux show -gqv @themux_git_text | { grep -oF '#("#{E:@_tmx_git_script}"' || true
printf 'script_path '
tmux show -gqv @_tmx_git_script | { grep -oF 'utils/git_status.sh' || true; }

# The baked core routes the active state through the dirty probe (an expanded
# draw would need a live repo path, so assert on the raw core).
printf 'core_active_switch '
tmux show -gqv @_tmx_module_git_core | { grep -oF '#{?#{E:@_tmx_git_dirty},' || true; } | sort -u
# The baked core routes the active state through the dirty probe. The module
# defaults state_target to `both`, but the stock text variant is `soft`
# (surface bg, plain fg — no accent channel), so the text style resolves the
# same in both states and the renderer collapses that switch: only the icon
# bg carries the conditional. An expanded draw would need a live repo path,
# so count on the raw core; grep -c would count lines and the core is a
# single line, hence grep -o | wc -l.
printf 'core_active_switch_slots '
tmux show -gqv @_tmx_module_git_core | { grep -oF '#{?#{E:@_tmx_git_dirty},' || true; } | wc -l | tr -d ' '

# With a text variant that displays the accent (solid: accent bg), the both
# default routes the dirty escalation into the text slot too — the whole
# pill warms instead of the icon-only two-tone `auto` used to leave. Three
# switches: icon bg, text bg, and the trailing bg re-assert after the text
# content (the guard that keeps a self-styled text from leaking).
tmux set -g @themux_git_text_variant "solid"
src
printf 'core_active_switch_slots_solid_text '
tmux show -gqv @_tmx_module_git_core | { grep -oF '#{?#{E:@_tmx_git_dirty},' || true; } | wc -l | tr -d ' '
tmux set -gu @themux_git_text_variant
src

# gitmux keeps its stock colours but sits on the theme's darkest step.
print_option @themux_gitmux_text_bg
Expand Down
3 changes: 2 additions & 1 deletion tests/git_module_expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ in_repo_probe rev-parse --is-inside-work-tree
dirty_probe #("#{E:@_tmx_git_script}" --dirty
text_invocation #("#{E:@_tmx_git_script}"
script_path utils/git_status.sh
core_active_switch #{?#{E:@_tmx_git_dirty},
core_active_switch_slots 1
core_active_switch_slots_solid_text 3

@themux_gitmux_text_bg #{E:@thm_crust}

Expand Down
4 changes: 2 additions & 2 deletions themux_options.conf
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ set -ogq @themux_module_leading_show "icon"
# follows the visible leading slot: leading when present, text when hidden.
# Stateful modules route @themux_<name>_active_color through this selector; cpu/ram
# default their own target to both so threshold colour still appears on icon and
# digits. @themux_<name>_state_target overrides one module; invalid values behave
# as auto.
# digits, and git defaults to both so a dirty tree warms the whole pill.
# @themux_<name>_state_target overrides one module; invalid values behave as auto.
set -ogq @themux_module_state_target "auto"

# Divider inserted by "|" between modules in the lists above. Modules/window-list
Expand Down