From 2bc93a41e9463ca3855d29783a2d8204988355d4 Mon Sep 17 00:00:00 2001 From: Izzy Gomez Date: Wed, 13 Mar 2024 00:51:06 -0400 Subject: [PATCH 1/6] update `TMUX_POWERLINE_CUR_SEGMENT_{BG,FG}` definition to make use of colours library --- lib/powerline.sh | 4 ++-- segments/vcs_branch.sh | 6 +++--- segments/vcs_modified.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/powerline.sh b/lib/powerline.sh index 8e8aceb1..40dc1a88 100644 --- a/lib/powerline.sh +++ b/lib/powerline.sh @@ -95,8 +95,8 @@ __process_scripts() { local script="$TMUX_POWERLINE_DIR_SEGMENTS/${powerline_segment[0]}.sh" fi - export TMUX_POWERLINE_CUR_SEGMENT_BG="${powerline_segment[1]}" - export TMUX_POWERLINE_CUR_SEGMENT_FG="${powerline_segment[2]}" + export TMUX_POWERLINE_CUR_SEGMENT_BG=$(__normalize_color "${powerline_segment[1]}") + export TMUX_POWERLINE_CUR_SEGMENT_FG=$(__normalize_color "${powerline_segment[2]}") source "$script" local output output=$(run_segment) diff --git a/segments/vcs_branch.sh b/segments/vcs_branch.sh index 5577d1d0..feab9eed 100755 --- a/segments/vcs_branch.sh +++ b/segments/vcs_branch.sh @@ -64,7 +64,7 @@ __parse_git_branch() { branch=${branch#refs\/heads\/} branch=$(__truncate_branch_name $branch) - echo -n "#[fg=colour${git_colour}]${branch_symbol} #[fg=colour${TMUX_POWERLINE_CUR_SEGMENT_FG}]${branch}" + echo -n "#[fg=colour${git_colour}]${branch_symbol} #[fg=${TMUX_POWERLINE_CUR_SEGMENT_FG}]${branch}" } # Show SVN branch. @@ -85,7 +85,7 @@ __parse_svn_branch() { local branch=$(echo "${svn_url}" | grep -E -o '[^/]+$') branch=$(__truncate_branch_name $branch) - echo "#[fg=colour${svn_colour}]${branch_symbol} #[fg=colour${TMUX_POWERLINE_CUR_SEGMENT_FG}]${branch}" + echo "#[fg=colour${svn_colour}]${branch_symbol} #[fg=${TMUX_POWERLINE_CUR_SEGMENT_FG}]${branch}" } __parse_hg_branch() { @@ -101,7 +101,7 @@ __parse_hg_branch() { local branch=$(echo "$summary" | grep 'branch:' | cut -d ' ' -f2) branch=$(__truncate_branch_name $branch) - echo "#[fg=colour${hg_colour}]${branch_symbol} #[fg=colour${TMUX_POWERLINE_CUR_SEGMENT_FG}]${branch}" + echo "#[fg=colour${hg_colour}]${branch_symbol} #[fg=${TMUX_POWERLINE_CUR_SEGMENT_FG}]${branch}" } diff --git a/segments/vcs_modified.sh b/segments/vcs_modified.sh index aa1e42e8..b8070b46 100755 --- a/segments/vcs_modified.sh +++ b/segments/vcs_modified.sh @@ -61,7 +61,7 @@ __parse_svn_stats() { #print if [[ $modified -gt 0 ]] ; then - local ret="#[fg=colour${TMUX_POWERLINE_CUR_SEGMENT_FG}]±${modified}" + local ret="#[fg=${TMUX_POWERLINE_CUR_SEGMENT_FG}]±${modified}" fi if [[ $conflicted -gt 0 ]] ; then local ret="#[fg=colour${svn_colour}]ϟ${conflicted} ${ret}" From 52894a1cbab1854e02746a9264f9f95215b39529 Mon Sep 17 00:00:00 2001 From: Izzy Gomez Date: Wed, 13 Mar 2024 00:52:39 -0400 Subject: [PATCH 2/6] update `mode_indicator.sh` segment for modern usage --- segments/mode_indicator.sh | 203 ++++++++++++++++++++++++++++++++++--- 1 file changed, 190 insertions(+), 13 deletions(-) diff --git a/segments/mode_indicator.sh b/segments/mode_indicator.sh index 56af2fe3..fd32ae7b 100644 --- a/segments/mode_indicator.sh +++ b/segments/mode_indicator.sh @@ -1,19 +1,196 @@ -# Indicator of pressing TMUX prefix, copy and insert modes. +# Segment that indicates status of various tmux modes. The list of supported +# modes & a brief description of each is as follows: +# +# - Normal mode: The default mode when you are simply using tmux. +# +# - Prefix mode: The mode when the tmux prefix key is pressed. +# +# - Mouse mode: While not definitionally a mode according to `man tmux`, this is +# a mode in the sense that it changes the behavior of tmux, & can be toggled +# on & off via the `tmux set-option -g mouse {on,off}` command; see `man tmux` +# for more details. +# +# - Copy mode: The mode when text is being copied. By default this is triggered +# by pressing the prefix key followed by '['; see `man tmux` for more details. +# +# Normal & prefix modes toggle between each other, so they occupy the same +# section of this segment. The other modes are independent of each other, so +# they each have their own part of the segment. By default, all modes are +# enabled, the text color for each node defaults to whatever foreground color is +# set in the user's theme, & the below list defines the default text for each +# mode & separator. These can all be overridden in `config.sh`. -prefix_pressed_text="PREFIX PRESSED" -insert_mode_text="INSERT" -copy_mode_text="COPY" -normal_mode_text="NORMAL" -separator="✤" +# Default values for the settings that this segment supports. +NORMAL_AND_PREFIX_MODE_ENABLED_DEFAULT="true" -prefix_mode_fg="colour226" -normal_mode_fg="colour16" -copy_mode_fg="colour82" -bg="colour33" +NORMAL_MODE_TEXT_DEFAULT="normal" +NORMAL_MODE_TEXT_COLOR_DEFAULT="$TMUX_POWERLINE_CUR_SEGMENT_FG" + +PREFIX_MODE_TEXT_DEFAULT="prefix" +PREFIX_MODE_TEXT_COLOR_DEFAULT="$TMUX_POWERLINE_CUR_SEGMENT_FG" + +MOUSE_MODE_ENABLED_DEFAULT="true" + +MOUSE_MODE_TEXT_DEFAULT="mouse" +MOUSE_MODE_TEXT_COLOR_DEFAULT="$TMUX_POWERLINE_CUR_SEGMENT_FG" + +COPY_MODE_ENABLED_DEFAULT="true" + +COPY_MODE_TEXT_DEFAULT="copy" +COPY_MODE_TEXT_COLOR_DEFAULT="$TMUX_POWERLINE_CUR_SEGMENT_FG" + +SEPARATOR_TEXT_DEFAULT="•" + +generate_segmentrc() { + read -d '' rccontents < Date: Wed, 13 Mar 2024 01:06:11 -0400 Subject: [PATCH 3/6] update `README` with mode segment info --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a8179e80..1730704f 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Some examples of segments available that you can add to your tmux status bar are * Date and time * Hostname * tmux info +# tmux mode indicator (normal/prefix, mouse, copy modes) * CWD in pane * Current X keyboard layout * Network download/upload speed From aeece33a9737eaf843b5ce955feaafff389062c6 Mon Sep 17 00:00:00 2001 From: Izzy Gomez Date: Wed, 13 Mar 2024 01:06:25 -0400 Subject: [PATCH 4/6] add (commented out) mode to default theme for visibility --- themes/default.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/default.sh b/themes/default.sh index bf493c59..98fc19d9 100644 --- a/themes/default.sh +++ b/themes/default.sh @@ -84,6 +84,7 @@ if [ -z $TMUX_POWERLINE_LEFT_STATUS_SEGMENTS ]; then TMUX_POWERLINE_LEFT_STATUS_SEGMENTS=( "tmux_session_info 148 234" \ "hostname 33 0" \ + #"mode_indicator 165 0" \ #"ifstat 30 255" \ #"ifstat_sys 30 255" \ "lan_ip 24 255 ${TMUX_POWERLINE_SEPARATOR_RIGHT_THIN}" \ @@ -107,7 +108,7 @@ if [ -z $TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS ]; then "load 237 167" \ #"tmux_mem_cpu_load 234 136" \ "battery 137 127" \ - #"air ${TMUX_POWERLINE_SEG_AIR_COLOR} 255" \ + #"air ${TMUX_POWERLINE_SEG_AIR_COLOR} 255" \ "weather 37 255" \ #"rainbarf 0 ${TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}" \ #"xkb_layout 125 117" \ From b6fb5010e9359303f166a5f2787b77ce385f0de5 Mon Sep 17 00:00:00 2001 From: Izzy Gomez Date: Wed, 13 Mar 2024 01:08:05 -0400 Subject: [PATCH 5/6] `README` fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1730704f..96ab1f8c 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Some examples of segments available that you can add to your tmux status bar are * Date and time * Hostname * tmux info -# tmux mode indicator (normal/prefix, mouse, copy modes) +* tmux mode indicator (normal/prefix, mouse, copy modes) * CWD in pane * Current X keyboard layout * Network download/upload speed From 2867398b67d3f4d03e6967020568b73bef4d0e2f Mon Sep 17 00:00:00 2001 From: Izzy Gomez Date: Wed, 13 Mar 2024 01:50:40 -0400 Subject: [PATCH 6/6] make space surrounding `separator` part of `separator` def --- segments/mode_indicator.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/segments/mode_indicator.sh b/segments/mode_indicator.sh index fd32ae7b..4c6feafe 100644 --- a/segments/mode_indicator.sh +++ b/segments/mode_indicator.sh @@ -39,7 +39,7 @@ COPY_MODE_ENABLED_DEFAULT="true" COPY_MODE_TEXT_DEFAULT="copy" COPY_MODE_TEXT_COLOR_DEFAULT="$TMUX_POWERLINE_CUR_SEGMENT_FG" -SEPARATOR_TEXT_DEFAULT="•" +SEPARATOR_TEXT_DEFAULT=" • " generate_segmentrc() { read -d '' rccontents <