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
|
||||
|
||||
|
|
@ -49,7 +49,8 @@ declare -A plugin_colors=(
|
|||
["time"]="light_blue text"
|
||||
["pomodoro"]="red text"
|
||||
["window"]="bg_main blue"
|
||||
["current"]="bg_main blue"
|
||||
["current"]="green text"
|
||||
["mode"]="duo_bg blue"
|
||||
)
|
||||
|
||||
get_plugin_colors() {
|
||||
|
|
@ -167,7 +168,8 @@ set_theme() {
|
|||
["time"]="text light_blue"
|
||||
["pomodoro"]="text red"
|
||||
["window"]="blue bg_main"
|
||||
["current"]="blue bg_main"
|
||||
["current"]="text red"
|
||||
["mode"]="blue bg_main"
|
||||
)
|
||||
fi
|
||||
}
|
||||
|
|
@ -206,6 +208,10 @@ status_bar() {
|
|||
|
||||
IFS=' ' read -r -a colors <<<"$(get_plugin_colors "$plugin")"
|
||||
script="#($current_dir/$plugin.sh)"
|
||||
# the mode module adds it's own spaces
|
||||
if [ "$plugin" != "mode" ]; then
|
||||
script=" $script "
|
||||
fi
|
||||
|
||||
if [ "$side" == "left" ]; then
|
||||
if $show_powerline; then
|
||||
|
|
@ -213,18 +219,18 @@ status_bar() {
|
|||
IFS=' ' read -r -a next_colors <<<"$(get_plugin_colors "$next_plugin")"
|
||||
pl_bg=${!next_colors[0]:-$bg_main}
|
||||
tmux set-option -ga status-left \
|
||||
"#[fg=${!colors[1]},bg=${!colors[0]}] $script #[fg=${!colors[0]},bg=${pl_bg},nobold,nounderscore,noitalics]${l_sep}"
|
||||
"#[fg=${!colors[1]},bg=${!colors[0]}]$script#[fg=${!colors[0]},bg=${pl_bg},nobold,nounderscore,noitalics]${l_sep}"
|
||||
pl_bg=${bg_main}
|
||||
else
|
||||
tmux set-option -ga status-left "#[fg=${!colors[1]},bg=${!colors[0]}] $script "
|
||||
tmux set-option -ga status-left "#[fg=${!colors[1]},bg=${!colors[0]}]$script"
|
||||
fi
|
||||
else
|
||||
if $show_powerline; then
|
||||
tmux set-option -ga status-right \
|
||||
"#[fg=${!colors[0]},bg=${pl_bg},nobold,nounderscore,noitalics]${r_sep}#[fg=${!colors[1]},bg=${!colors[0]}] $script "
|
||||
"#[fg=${!colors[0]},bg=${pl_bg},nobold,nounderscore,noitalics]${r_sep}#[fg=${!colors[1]},bg=${!colors[0]}]$script"
|
||||
pl_bg=${!colors[0]}
|
||||
else
|
||||
tmux set-option -ga status-right "#[fg=${!colors[1]},bg=${!colors[0]}] $script "
|
||||
tmux set-option -ga status-right "#[fg=${!colors[1]},bg=${!colors[0]}]$script"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue