Files
chezmoi/dot_config/tmux/executable_tmux-battery-insert.sh

8 lines
403 B
Bash

#!/usr/bin/env bash
# Insert the battery segment in tmux-power's status-right, right before the time segment.
batt=' #{battery_color_fg}#{battery_icon_status} #{battery_percentage} '
icon=$(tmux show -gv @tmux_power_time_icon)
cur=$(tmux show -gv status-right)
new=$(BATT="$batt" ICON="$icon" perl -0pe 's/((?:#\[[^\]]*\])+[^#]*\Q$ENV{ICON}\E)/$ENV{BATT}$1/' <<< "$cur")
tmux set -g status-right "$new"