From caad7d000a1c01d1d10aa341a56ddf3277c9dc0c Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 27 Nov 2023 23:15:57 +1100 Subject: [PATCH] Add mode indicator to statusline (pretty big hack ATM) --- .../tmux-powerline/segments/mode_indicator.sh | 30 +++++++++++++++++++ dot-config/tmux-powerline/themes/00dani.sh | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 dot-config/tmux-powerline/segments/mode_indicator.sh diff --git a/dot-config/tmux-powerline/segments/mode_indicator.sh b/dot-config/tmux-powerline/segments/mode_indicator.sh new file mode 100644 index 0000000..db94bc6 --- /dev/null +++ b/dot-config/tmux-powerline/segments/mode_indicator.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Indicator of pressing TMUX prefix, copy and insert modes. +declare -A MODE_BG MODE_LABEL +MODE_BG=( + [P]=blue + [C]=yellow + [S]=red + [T]=cyan +) +MODE_LABEL=( + [P]=WAIT + [C]=COPY + [S]=SYNC + [T]=TMUX +) + +__choose_for_mode() { + local -n modes=$1 + echo -n "#{?client_prefix,${modes[P]},#{?pane_in_mode,${modes[C]},#{?pane_synchronized,${modes[S]},${modes[T]}}}}" +} + +__update_segment_bg() { + export TMUX_POWERLINE_CUR_SEGMENT_BG="$(tmux display-message -p "$(__choose_for_mode MODE_BG)")" +} +__update_segment_bg + +run_segment() { + echo -n "#[fg=black,bg=$(__choose_for_mode MODE_BG)] $(__choose_for_mode MODE_LABEL)" + return 0 +} diff --git a/dot-config/tmux-powerline/themes/00dani.sh b/dot-config/tmux-powerline/themes/00dani.sh index 8d51fa3..f92c50d 100644 --- a/dot-config/tmux-powerline/themes/00dani.sh +++ b/dot-config/tmux-powerline/themes/00dani.sh @@ -93,7 +93,7 @@ fi if [[ -z $TMUX_POWERLINE_LEFT_STATUS_SEGMENTS ]]; then TMUX_POWERLINE_LEFT_STATUS_SEGMENTS=( - "mode_indicator 33" + "mode_indicator default default ${TMUX_POWERLINE_SEPARATOR_RIGHT_BOLD} default default both_disable" #"tmux_session_info 148 234" #"hostname 33 0" #"ifstat 30 255"