mirror of
https://github.com/TECHNOFAB11/tmux2k.git
synced 2025-12-11 23:50:08 +01:00
47 lines
1.6 KiB
Bash
Executable file
47 lines
1.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$current_dir"/utils.sh
|
|
|
|
# Define styles
|
|
STYLE_COPY="#[bg=black,fg=#ffff00]"
|
|
STYLE_PREFIX="#[bg=black,fg=#00ee00]"
|
|
STYLE_SYNC="#[bg=black,fg=#ff0000]"
|
|
STYLE_KNOWN_TABLE="#[bg=black,fg=#00aaff]"
|
|
STYLE_TABLE="#[bg=black,fg=#0066ff]"
|
|
STYLE_NORMAL="#[bg=black,fg=red]"
|
|
|
|
main() {
|
|
# Get active client and active pane for it
|
|
active_client=$(tmux display -p '#{client_tty}')
|
|
active_pane=$(tmux list-panes -a -F '#{pane_active} #{pane_tty} #{pane_id}' | \
|
|
awk -v tty="$active_client" '$1 == "1" && $2 == tty { print $3 }')
|
|
|
|
# Check states relative to that pane
|
|
pane_in_mode=$(tmux display -p -t "$active_pane" '#{pane_in_mode}')
|
|
client_prefix=$(tmux display -p '#{client_prefix}')
|
|
pane_sync=$(tmux display -p -t "$active_pane" '#{pane_synchronized}')
|
|
key_table=$(tmux display -p '#{client_key_table}')
|
|
|
|
# Mode priority logic
|
|
if [ "$pane_in_mode" = "1" ]; then
|
|
echo "${STYLE_COPY} COPY #[default]"
|
|
elif [ "$key_table" != "root" ] && [ "$key_table" != "prefix" ]; then
|
|
if [ "$key_table" = "resize" ]; then
|
|
echo "${STYLE_KNOWN_TABLE} RESIZE #[default]"
|
|
elif [ "$key_table" = "cpyrt" ]; then
|
|
echo "${STYLE_KNOWN_TABLE} RAT #[default]"
|
|
else
|
|
echo "${STYLE_TABLE} TABLE:$key_table #[default]"
|
|
fi
|
|
elif [ "$client_prefix" = "1" ]; then
|
|
echo "${STYLE_PREFIX} PREFIX #[default]"
|
|
elif [ "$pane_sync" = "1" ]; then
|
|
echo "${STYLE_SYNC} SYNC #[default]"
|
|
else
|
|
echo "${STYLE_NORMAL} TMUX #[default]"
|
|
fi
|
|
}
|
|
|
|
main
|
|
|