mirror of
https://github.com/TECHNOFAB11/tmux2k.git
synced 2025-12-11 23:50:08 +01:00
feat: add mode indicator
This commit is contained in:
parent
2935a9ea7f
commit
feef9a9d6d
2 changed files with 59 additions and 6 deletions
47
scripts/mode.sh
Executable file
47
scripts/mode.sh
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue