From 80945039ba87f0637fc0a1c42f93ecbbe332ada7 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 7 Sep 2024 21:08:27 +0200 Subject: [PATCH 01/10] feat: define dark and light color palettes --- src/palette_gruvbox_dark.sh | 45 ++++++++++++++++++++++++++++++++++++ src/palette_gruvbox_light.sh | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/palette_gruvbox_dark.sh create mode 100644 src/palette_gruvbox_light.sh diff --git a/src/palette_gruvbox_dark.sh b/src/palette_gruvbox_dark.sh new file mode 100644 index 0000000..dc87b89 --- /dev/null +++ b/src/palette_gruvbox_dark.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +########################## +# gruvbox dark pallete +########################## + +#### +# When using 'colour124' you are using the color default in terminal pallete. +# This could be important for people which terminals support only 256 colors +# and does not support HEX values. +# +# The names of colors used from https://github.com/morhetz/gruvbox + +col_bg=colour235 +col_bg0_h=colour234 +col_bg0=colour235 +col_bg1=colour237 +col_bg2=colour239 +col_bg3=colour241 +col_bg4=colour243 +col_gray0=colour246 +col_gray1=colour245 +col_gray2=colour245 +col_bg0_s=colour236 +col_fg=colour223 +col_fg4=colour246 +col_fg3=colour248 +col_fg2=colour250 +col_fg1=colour223 +col_fg0=colour229 + +col_red=colour124 +col_red2=colour167 +col_green=colour106 +col_green2=colour142 +col_yellow=colour172 +col_yellow2=colour214 +col_blue=colour66 +col_blue2=colour109 +col_purple=colour132 +col_purple2=colour175 +col_aqua=colour72 +col_aqua2=colour108 +col_orange=colour166 +col_orange2=colour208 diff --git a/src/palette_gruvbox_light.sh b/src/palette_gruvbox_light.sh new file mode 100644 index 0000000..bf9b75f --- /dev/null +++ b/src/palette_gruvbox_light.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +########################## +# gruvbox dark pallete +########################## + +#### +# When using 'colour124' you are using the color default in terminal pallete. +# This could be important for people which terminals support only 256 colors +# and does not support HEX values. +# +# The names of colors used from https://github.com/morhetz/gruvbox + +col_bg=colour229 +col_bg0_h=colour230 +col_bg0=colour229 +col_bg1=colour223 +col_bg2=colour250 +col_bg3=colour248 +col_bg4=colour246 +col_gray0=colour246 +col_gray1=colour245 +col_gray2=colour244 +col_bg0_s=colour228 +col_fg=colour223 +col_fg4=colour243 +col_fg3=colour241 +col_fg2=colour239 +col_fg1=colour237 +col_fg0=colour235 + +col_red=colour124 +col_red2=colour88 +col_green=colour106 +col_green2=colour100 +col_yellow=colour172 +col_yellow2=colour136 +col_blue=colour66 +col_blue2=colour24 +col_purple=colour132 +col_purple2=colour96 +col_aqua=colour72 +col_aqua2=colour66 +col_orange=colour166 +col_orange2=colour130 From aac51493cb67cb45c04cad4de965611ed8e08884 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sat, 7 Sep 2024 21:09:00 +0200 Subject: [PATCH 02/10] feat: add customization of status-right & status-left sections --- src/gruvbox-main.sh | 86 +++++++++++++++++++++++++++++++-------- src/helper_methods.sh | 19 +++++++++ src/theme_gruvbox_dark.sh | 58 ++++++++++++++++++++++++++ src/tmux_utils.sh | 36 ++++++++++++++++ tmux-gruvbox-dark.conf | 2 +- 5 files changed, 184 insertions(+), 17 deletions(-) create mode 100644 src/helper_methods.sh create mode 100644 src/theme_gruvbox_dark.sh create mode 100644 src/tmux_utils.sh diff --git a/src/gruvbox-main.sh b/src/gruvbox-main.sh index 271bc42..19218d8 100755 --- a/src/gruvbox-main.sh +++ b/src/gruvbox-main.sh @@ -3,25 +3,79 @@ SCRIPT_SRC="$(dirname "${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}")" readonly SCRIPT_SRC CURRENT_DIR=$(cd "${SCRIPT_SRC}" >/dev/null 2>&1 && pwd) readonly CURRENT_DIR -readonly THEME_OPTION="@tmux-gruvbox" -readonly DEFAULT_THEME="dark" +readonly CURRENT_DIR -get_theme() { - local option="$1" - local default_value="$2" - local option_value - option_value=$(tmux show-option -gqv "$option") - if [ -z "$option_value" ]; then - echo "$default_value" - else - echo "$option_value" - fi -} +# hold the array of all command to configure tmux theme +declate -a TMUX_CMDS + +# load libraries +source "${CURRENT_DIR}/src/helper_methods.sh" +source "${CURRENT_DIR}/src/tmux_utils.sh" +source "${CURRENT_DIR}/src/theme_gruvbox_dark.sh" + +readonly TMUX_GRUVBOX="@tmux-gruvbox" +readonly TMUX_GRUVBOX_THEME="@tmux-gruvbox-theme" +readonly TMUX_GRUVBOX_LEFT_STATUS="@tmux-gruvbox-left-status" +readonly TMUX_GRUVBOX_RIGHT_STAUTS="@tmux-gruvbox-right-status" +readonly TMUX_GRUVBOX_WINDOW_STATUS_CURRENT_FORMAT="@tmux-gruvbox-window-status-current-format" +readonly TMUX_GRUVBOX_WINDOW_STATUS_FORMAT="@tmux-gruvbox-window-status-format" + +# define the reference names for further custom options +tmux_append_seto "${TMUX_GRUVBOX}" +tmux_append_seto "${TMUX_GRUVBOX_THEME}" +tmux_append_seto "${TMUX_GRUVBOX_LEFT_STATUS}" +tmux_append_seto "${TMUX_GRUVBOX_RIGHT_STAUTS}" +tmux_append_seto "${TMUX_GRUVBOX_WINDOW_STATUS_CURRENT_FORMAT}" +tmux_append_seto "${TMUX_GRUVBOX_WINDOW_STATUS_FORMAT}" + +print_array TMUX_CMDS # print options +tmux "${TMUX_CMDS[@]}" # execute options +TMUX_CMDS=() # clean main() { - local theme - theme=$(get_theme "$THEME_OPTION" "$DEFAULT_THEME") - tmux source-file "$CURRENT_DIR/tmux-gruvbox-${theme}.conf" + local _theme + _theme=$(tmux_get_option "$TMUX_GRUVBOX" "$DEFAULT_THEME") + + # load proper palette for the theme soon to avoid additional variable interpolation + case $_theme in + light) + source "${CURRENT_DIR}/src/palette_gruvbox_light.sh" + ;; + dark | *) + source "${CURRENT_DIR}/src/palette_gruvbox_dark.sh" + ;; + esac + + # defaults for theme option + DEFAULT_THEME="dark" + DEFAULT_LEFT_STATUS="#[bg=${col_bg3},fg=${col_fg3}] #S #[bg=${col_bg1},fg=${col_bg3},nobold,noitalics,nounderscore]" + DEFAULT_RIGHT_STATUS="#[bg=${col_bg1},fg=${col_bg2},nobold,nounderscore,noitalics]#[bg=${col_bg2},fg=${col_fg4}] %Y-%m-%d  %H:%M #[bg=${col_bg2},fg=${col_fg3},nobold,noitalics,nounderscore]#[bg=${col_fg3},fg=${col_bg1}] #h #{tmux_mode_indicator}" + DEFAULT_WINDOW_STATUS_CURRENT_FORMAT="#[bg=${col_yellow2},fg=${col_bg1},nobold,noitalics,nounderscore]#[bg=${col_yellow2},fg=${col_bg2}] #I #[bg=${col_yellow2},fg=${col_bg2},bold] #W#{?window_zoomed_flag,*Z,} #[bg=${col_bg1},fg=${col_yellow2},nobold,noitalics,nounderscore]" + DEFAULT_WINDOW_STATUS_FORMAT="#[bg=${col_bg2},fg=${col_bg1},noitalics]#[bg=${col_bg2},fg=${col_fg1}] #I #[bg=${col_bg2},fg=${col_fg1}] #W #[bg=${col_bg1},fg=${col_bg2},noitalics]" + + _status_left=$(tmux_get_option "$TMUX_GRUVBOX_LEFT_STATUS" "$DEFAULT_LEFT_STATUS") + _status_right=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS" "$DEFAULT_RIGHT_STATUS") + _window_status_current_format=$(tmux_get_option "$TMUX_GRUVBOX_WINDOW_STATUS_CURRENT_FORMAT" "$DEFAULT_WINDOW_STATUS_CURRENT_FORMAT") + _window_status_format=$(tmux_get_option "$TMUX_GRUVBOX_WINDOW_STATUS_FORMAT" "$DEFAULT_WINDOW_STATUS_FORMAT") + + theme_args=( + "$_status_left" + "$_status_right" + "$_window_status_current_format" + "$_window_status_format" + ) + + case $_theme in + light) + set_light_theme "${theme_args[@]}" + ;; + dark | *) + set_dark_theme "${theme_args[@]}" + ;; + esac + + # execute commands with tmux as array of options + tmux "${TMUX_CMDS[@]}" } main "$@" diff --git a/src/helper_methods.sh b/src/helper_methods.sh new file mode 100644 index 0000000..175a5a3 --- /dev/null +++ b/src/helper_methods.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# simply print passed array +# +# example +# +# myarray=() +# print_array myarray +# +print_array() { + local -n arr # -n available over bash 4.3 + arr=$1 + + echo "" + echo "begin >>>" + printf "%s\n" "${arr[@]}" + echo "<<< end" + echo "" +} diff --git a/src/theme_gruvbox_dark.sh b/src/theme_gruvbox_dark.sh new file mode 100644 index 0000000..4ae4a3d --- /dev/null +++ b/src/theme_gruvbox_dark.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# themes may use different colors in sets therefore we setup dark and light separately +set_dark_theme() { + local _left_status_value _right_status_value _window_status_current_format + _left_status_value=$1 + _right_status_value=$2 + _window_status_current_format=$3 + _window_status_format=$4 + + tmux_append_seto "status" "on" + + # default statusbar color + tmux_append_seto "status-style" "bg=${col_bg1},fg=${col_fg1}" + + # default window title colors + tmux_append_setwo "window-status-style" "bg=${col_yellow2},fg=${col_bg1}" + + # default window with an activity alert + tmux_append_setwo "window-status-activity-style" "bg=${col_bg1},fg=${col_fg3}" + + # active window title colors + tmux_append_setwo "window-status-current-style" "bg=default,fg=${col_bg1}" # TODO cosider removing red! + + # pane border + tmux_append_seto "pane-active-border-style" "fg=${col_fg2}" + tmux_append_seto "pane-border-style" "fg=${col_bg1}" + + # message infos + tmux_append_seto "message-style" "bg=${col_bg2},fg=${col_fg1}" + + # writing commands inactive + tmux_append_seto "message-command-style" "bg=${col_fg3},fg=${col_bg1}" + + # pane number display + tmux_append_seto "display-panes-active-colour" "${col_fg2}" + tmux_append_seto "display-panes-colour" "${col_bg1}" + + # clock + tmux_append_setwo "clock-mode-colour" "${col_blue2}" + + # bell + tmux_append_setwo "window-status-bell-style" "bg=${col_red2},fg=${col_bg}" + + ## Theme settings mixed with colors (unfortunately, but there is no cleaner way) + tmux_append_seto "status-justify" "left" + tmux_append_seto "status-left-style" none + tmux_append_seto "status-left-length" "80" + tmux_append_seto "status-right-style" none + tmux_append_seto "status-right-length" "80" + tmux_append_setwo "window-status-separator" "" + + tmux_append_seto "status-left" "${_left_status_value}" + tmux_append_seto "status-right" "${_right_status_value}" + + tmux_append_setwo "window-status-current-format" "${_window_status_current_format}" + tmux_append_setwo "window-status-format" "${_window_status_format}" +} diff --git a/src/tmux_utils.sh b/src/tmux_utils.sh new file mode 100644 index 0000000..6e2ae12 --- /dev/null +++ b/src/tmux_utils.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# get desired option from tmux or default +tmux_get_option() { + local _option _default_value + _option="$1" + _default_value="$2" + + local _option_value + _option_value=$(tmux show-option -gqv "$_option") + if [ -z "$_option_value" ]; then + echo "$_default_value" + else + echo "$_option_value" + fi +} + +# append preconfigured tmux set-option to global array +tmux_append_seto() { + local _option _value _result + _option="$1" + _value="$2" + TMUX_CMDS+=("set-option" "-gq" "${_option}" "${_value}" ";") + # _retult=("set-option -gq" "${_option}" "${_value}" ";") + # echo "${_retult[*]}" +} + +# append preconfigured tmux set-window-option to global array +tmux_append_setwo() { + local _option _value _result + _option="$1" + _value="$2" + TMUX_CMDS+=("set-window-option" "-gq" "${_option}" "${_value}" ";") + # _retult=("set-window-option -gq" "${_option}" "${_value}" ";") + # echo "${_retult[*]}" +} diff --git a/tmux-gruvbox-dark.conf b/tmux-gruvbox-dark.conf index 8d86699..93700c5 100644 --- a/tmux-gruvbox-dark.conf +++ b/tmux-gruvbox-dark.conf @@ -42,7 +42,7 @@ set-option -g status-right-length "80" set-window-option -g window-status-separator "" set-option -g status-left "#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]" -set-option -g status-right "#[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %Y-%m-%d  %H:%M #[bg=colour239,fg=colour248,nobold,noitalics,nounderscore]#[bg=colour248,fg=colour237] #h " +set-option -g status-right "#[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %Y-%m-%d  %H:%M #[bg=colour239,fg=colour248,nobold,noitalics,nounderscore]#[bg=colour248,fg=colour237] #h #{tmux_mode_indicator}" set-window-option -g window-status-current-format "#[bg=colour214,fg=colour237,nobold,noitalics,nounderscore]#[bg=colour214,fg=colour239] #I #[bg=colour214,fg=colour239,bold] #W#{?window_zoomed_flag,*Z,} #[bg=colour237,fg=colour214,nobold,noitalics,nounderscore]" set-window-option -g window-status-format "#[bg=colour239,fg=colour237,noitalics]#[bg=colour239,fg=colour223] #I #[bg=colour239,fg=colour223] #W #[bg=colour237,fg=colour239,noitalics]" From 8498b5f6ebc1d3ad1c84ff874ea4efda9d03c1fa Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sun, 8 Sep 2024 22:22:46 +0200 Subject: [PATCH 03/10] feat: rename to gruvbox_dark256 and implement alpha option --- src/gruvbox-main.sh | 108 +++++++++--------- src/theme_gruvbox_dark256.sh | 75 ++++++++++++ ...vbox_dark.sh => theme_gruvbox_light256.sh} | 20 ++-- src/tmux_utils.sh | 66 +++++++++-- 4 files changed, 193 insertions(+), 76 deletions(-) create mode 100644 src/theme_gruvbox_dark256.sh rename src/{theme_gruvbox_dark.sh => theme_gruvbox_light256.sh} (60%) diff --git a/src/gruvbox-main.sh b/src/gruvbox-main.sh index 19218d8..9701c08 100755 --- a/src/gruvbox-main.sh +++ b/src/gruvbox-main.sh @@ -11,71 +11,71 @@ declate -a TMUX_CMDS # load libraries source "${CURRENT_DIR}/src/helper_methods.sh" source "${CURRENT_DIR}/src/tmux_utils.sh" -source "${CURRENT_DIR}/src/theme_gruvbox_dark.sh" +source "${CURRENT_DIR}/src/theme_gruvbox_dark256.sh" +source "${CURRENT_DIR}/src/theme_gruvbox_light256.sh" readonly TMUX_GRUVBOX="@tmux-gruvbox" -readonly TMUX_GRUVBOX_THEME="@tmux-gruvbox-theme" -readonly TMUX_GRUVBOX_LEFT_STATUS="@tmux-gruvbox-left-status" -readonly TMUX_GRUVBOX_RIGHT_STAUTS="@tmux-gruvbox-right-status" -readonly TMUX_GRUVBOX_WINDOW_STATUS_CURRENT_FORMAT="@tmux-gruvbox-window-status-current-format" -readonly TMUX_GRUVBOX_WINDOW_STATUS_FORMAT="@tmux-gruvbox-window-status-format" +readonly TMUX_GRUVBOX_STATUSBAR_ALPHA="@tmux-gruvbox-statusbar-alpha" +readonly TMUX_GRUVBOX_LEFT_STATUS_A="@tmux-gruvbox-left-status-a" +readonly TMUX_GRUVBOX_RIGHT_STAUTS_X="@tmux-gruvbox-right-status-x" +readonly TMUX_GRUVBOX_RIGHT_STAUTS_Y="@tmux-gruvbox-right-status-y" +readonly TMUX_GRUVBOX_RIGHT_STAUTS_Z="@tmux-gruvbox-right-status-z" -# define the reference names for further custom options -tmux_append_seto "${TMUX_GRUVBOX}" -tmux_append_seto "${TMUX_GRUVBOX_THEME}" -tmux_append_seto "${TMUX_GRUVBOX_LEFT_STATUS}" -tmux_append_seto "${TMUX_GRUVBOX_RIGHT_STAUTS}" -tmux_append_seto "${TMUX_GRUVBOX_WINDOW_STATUS_CURRENT_FORMAT}" -tmux_append_seto "${TMUX_GRUVBOX_WINDOW_STATUS_FORMAT}" - -print_array TMUX_CMDS # print options -tmux "${TMUX_CMDS[@]}" # execute options -TMUX_CMDS=() # clean +# define simple theme options (no color interpolation required) +DEFAULT_THEME="dark" +DEFAULT_STATUSBAR_ALPHA=false +# defaults for theme option (with color interpolation) +DEFAULT_LEFT_STATUS_A='#S' +DEFAULT_RIGHT_STATUS_X='%Y-%m-%d' +DEFAULT_RIGHT_STATUS_Y='%H:%M' +DEFAULT_RIGHT_STATUS_Z='#h' main() { - local _theme - _theme=$(tmux_get_option "$TMUX_GRUVBOX" "$DEFAULT_THEME") + TMUX_CMDS=() # clear - # load proper palette for the theme soon to avoid additional variable interpolation - case $_theme in - light) - source "${CURRENT_DIR}/src/palette_gruvbox_light.sh" - ;; - dark | *) - source "${CURRENT_DIR}/src/palette_gruvbox_dark.sh" - ;; - esac + # load proper palette for the theme asap to avoid additional variable interpolation + local _theme + _theme=$(tmux_get_option "${TMUX_GRUVBOX}" "${DEFAULT_THEME}") + _statusbar_alpha=$(tmux_get_option "${TMUX_GRUVBOX_STATUSBAR_ALPHA}" "${DEFAULT_STATUSBAR_ALPHA}") - # defaults for theme option - DEFAULT_THEME="dark" - DEFAULT_LEFT_STATUS="#[bg=${col_bg3},fg=${col_fg3}] #S #[bg=${col_bg1},fg=${col_bg3},nobold,noitalics,nounderscore]" - DEFAULT_RIGHT_STATUS="#[bg=${col_bg1},fg=${col_bg2},nobold,nounderscore,noitalics]#[bg=${col_bg2},fg=${col_fg4}] %Y-%m-%d  %H:%M #[bg=${col_bg2},fg=${col_fg3},nobold,noitalics,nounderscore]#[bg=${col_fg3},fg=${col_bg1}] #h #{tmux_mode_indicator}" - DEFAULT_WINDOW_STATUS_CURRENT_FORMAT="#[bg=${col_yellow2},fg=${col_bg1},nobold,noitalics,nounderscore]#[bg=${col_yellow2},fg=${col_bg2}] #I #[bg=${col_yellow2},fg=${col_bg2},bold] #W#{?window_zoomed_flag,*Z,} #[bg=${col_bg1},fg=${col_yellow2},nobold,noitalics,nounderscore]" - DEFAULT_WINDOW_STATUS_FORMAT="#[bg=${col_bg2},fg=${col_bg1},noitalics]#[bg=${col_bg2},fg=${col_fg1}] #I #[bg=${col_bg2},fg=${col_fg1}] #W #[bg=${col_bg1},fg=${col_bg2},noitalics]" + case "$_theme" in + light | light256) + source "${CURRENT_DIR}/src/palette_gruvbox_light.sh" + source "${CURRENT_DIR}/src/theme_gruvbox_light256.sh" + ;; + dark | dark256 | *) + source "${CURRENT_DIR}/src/palette_gruvbox_dark.sh" + source "${CURRENT_DIR}/src/theme_gruvbox_dark256.sh" + ;; + esac - _status_left=$(tmux_get_option "$TMUX_GRUVBOX_LEFT_STATUS" "$DEFAULT_LEFT_STATUS") - _status_right=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS" "$DEFAULT_RIGHT_STATUS") - _window_status_current_format=$(tmux_get_option "$TMUX_GRUVBOX_WINDOW_STATUS_CURRENT_FORMAT" "$DEFAULT_WINDOW_STATUS_CURRENT_FORMAT") - _window_status_format=$(tmux_get_option "$TMUX_GRUVBOX_WINDOW_STATUS_FORMAT" "$DEFAULT_WINDOW_STATUS_FORMAT") + local _status_left _status_right _window_status_current_format _window_status_format + _status_left_a=$(tmux_get_option "$TMUX_GRUVBOX_LEFT_STATUS_A" "$DEFAULT_LEFT_STATUS_A") + _status_right_x=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_X" "$DEFAULT_RIGHT_STATUS_X") + _status_right_y=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_Y" "$DEFAULT_RIGHT_STATUS_Y") + _status_right_z=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_Z" "$DEFAULT_RIGHT_STATUS_Z") - theme_args=( - "$_status_left" - "$_status_right" - "$_window_status_current_format" - "$_window_status_format" - ) + theme_args=( + "$_status_left_a" + "$_status_right_x" + "$_status_right_y" + "$_status_right_z" + "$_statusbar_alpha" + ) - case $_theme in - light) - set_light_theme "${theme_args[@]}" - ;; - dark | *) - set_dark_theme "${theme_args[@]}" - ;; - esac + case $_theme in + light | light256) + theme_set_light_256 "${theme_args[@]}" + ;; + dark | dark256 | *) + theme_set_dark_256 "${theme_args[@]}" + ;; + esac - # execute commands with tmux as array of options - tmux "${TMUX_CMDS[@]}" + # execute commands with tmux as array of options + tmux "${TMUX_CMDS[@]}" } main "$@" + +# vi: ft=bash diff --git a/src/theme_gruvbox_dark256.sh b/src/theme_gruvbox_dark256.sh new file mode 100644 index 0000000..0dcc014 --- /dev/null +++ b/src/theme_gruvbox_dark256.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +# Themes may use different colors in sets therefore we setup dark and light +# separately. +# +# shellcheck disable=SC2154 +theme_set_dark_256() { + local _left_status_a _right_status_x _right_status_y _right_status_z _statusbar_alpha + _left_status_a=$1 + _right_status_x=$2 + _right_status_y=$3 + _right_status_z=$4 + _statusbar_alpha=$5 + + tmux_append_seto "status" "on" + + # default statusbar bg color + local _statusbar_bg="${col_bg1}" + if [[ "$_statusbar_alpha" == "true" ]]; then _statusbar_bg="default"; fi + tmux_append_seto "status-style" "bg=${_statusbar_bg},fg=${col_fg1}" + + # default window title colors + local _window_title_bg=${col_yellow2} + if [[ "$_statusbar_alpha" == "true" ]]; then _window_title_bg="default"; fi + tmux_append_setwo "window-status-style" "bg=${_window_title_bg},fg=${col_bg1}" + + # default window with an activity alert + tmux_append_setwo "window-status-activity-style" "bg=${col_bg1},fg=${col_fg3}" + + # active window title colors + local active_window_title_bg=${col_yellow2} + if [[ "$_statusbar_alpha" == "true" ]]; then active_window_title_bg="default"; fi + tmux_append_setwo "window-status-current-style" "bg=${active_window_title_bg},fg=${col_bg1}" # TODO cosider removing red! + + # pane border + tmux_append_seto "pane-active-border-style" "fg=${col_fg2}" + tmux_append_seto "pane-border-style" "fg=${col_bg1}" + + # message infos + tmux_append_seto "message-style" "bg=${col_bg2},fg=${col_fg1}" + + # writing commands inactive + tmux_append_seto "message-command-style" "bg=${col_fg3},fg=${col_bg1}" + + # pane number display + tmux_append_seto "display-panes-active-colour" "${col_fg2}" + tmux_append_seto "display-panes-colour" "${col_bg1}" + + # clock + tmux_append_setwo "clock-mode-colour" "${col_blue2}" + + # bell + tmux_append_setwo "window-status-bell-style" "bg=${col_red2},fg=${col_bg}" + + ## Theme settings mixed with colors (unfortunately, but there is no cleaner way) + tmux_append_seto "status-justify" "left" + tmux_append_seto "status-left-style" none + tmux_append_seto "status-left-length" "80" + tmux_append_seto "status-right-style" none + tmux_append_seto "status-right-length" "80" + tmux_append_setwo "window-status-separator" "" + + tmux_append_seto "status-left" "#[bg=${col_bg3},fg=${col_fg3}] ${_left_status_a} #[bg=${col_bg1},fg=${col_bg3},nobold,noitalics,nounderscore]" + + # right status + local _status_right_bg=${col_bg1} + if [[ "$_statusbar_alpha" == "true" ]]; then _status_right_bg="default"; fi + tmux_append_seto "status-right" "#[bg=${_status_right_bg},fg=${col_bg2},nobold,nounderscore,noitalics]#[bg=${col_bg2},fg=${col_fg4}] ${_right_status_x}  ${_right_status_y} #[bg=${col_bg2},fg=${col_fg3},nobold,noitalics,nounderscore]#[bg=${col_fg3},fg=${col_bg1}] ${_right_status_z}" + + # current window + tmux_append_setwo "window-status-current-format" "#[bg=${col_yellow2},fg=${col_bg1},nobold,noitalics,nounderscore]#[bg=${col_yellow2},fg=${col_bg2}] #I #[bg=${col_yellow2},fg=${col_bg2},bold] #W#{?window_zoomed_flag,*Z,} #{?window_end_flag,#[bg=default],#[bg=colour237]}#[fg=${col_yellow2},nobold,noitalics,nounderscore]" + + # default window + tmux_append_setwo "window-status-format" "#[bg=${col_bg2},fg=${col_bg1},noitalics]#[bg=${col_bg2},fg=${col_fg1}] #I #[bg=${col_bg2},fg=${col_fg1}] #W #{?window_end_flag,#[bg=default],#[bg=colour237]}#[fg=${col_bg2},noitalics]" +} diff --git a/src/theme_gruvbox_dark.sh b/src/theme_gruvbox_light256.sh similarity index 60% rename from src/theme_gruvbox_dark.sh rename to src/theme_gruvbox_light256.sh index 4ae4a3d..aaa5246 100644 --- a/src/theme_gruvbox_dark.sh +++ b/src/theme_gruvbox_light256.sh @@ -1,12 +1,12 @@ #!/bin/bash # themes may use different colors in sets therefore we setup dark and light separately -set_dark_theme() { - local _left_status_value _right_status_value _window_status_current_format - _left_status_value=$1 - _right_status_value=$2 - _window_status_current_format=$3 - _window_status_format=$4 +theme_set_light_256() { + local _left_status_value _right_status_value _window_status_current_format _window_status_format + _left_status_a=$1 + _right_status_x=$2 + _right_status_y=$3 + _right_status_z=$4 tmux_append_seto "status" "on" @@ -50,9 +50,9 @@ set_dark_theme() { tmux_append_seto "status-right-length" "80" tmux_append_setwo "window-status-separator" "" - tmux_append_seto "status-left" "${_left_status_value}" - tmux_append_seto "status-right" "${_right_status_value}" + tmux_append_seto "status-left" "#[bg=${col_bg3},fg=${col_fg3}] ${_left_status_a} #[bg=${col_bg1},fg=${col_bg3},nobold,noitalics,nounderscore]" + tmux_append_seto "status-right" "#[bg=${col_bg1},fg=${col_bg2},nobold,nounderscore,noitalics]#[bg=${col_bg2},fg=${col_fg4}] ${_right_status_x}  ${_right_status_y} #[bg=${col_bg2},fg=${col_fg3},nobold,noitalics,nounderscore]#[bg=${col_fg3},fg=${col_bg1}] ${_right_status_z}" - tmux_append_setwo "window-status-current-format" "${_window_status_current_format}" - tmux_append_setwo "window-status-format" "${_window_status_format}" + tmux_append_setwo "window-status-current-format" "#[bg=${col_yellow2},fg=${col_bg1},nobold,noitalics,nounderscore]#[bg=${col_yellow2},fg=${col_bg2}] #I #[bg=${col_yellow2},fg=${col_bg2},bold] #W#{?window_zoomed_flag,*Z,} #[bg=${col_bg1},fg=${col_yellow2},nobold,noitalics,nounderscore]" + tmux_append_setwo "window-status-format" "#[bg=${col_bg2},fg=${col_bg1},noitalics]#[bg=${col_bg2},fg=${col_fg1}] #I #[bg=${col_bg2},fg=${col_fg1}] #W #[bg=${col_bg1},fg=${col_bg2},noitalics]" } diff --git a/src/tmux_utils.sh b/src/tmux_utils.sh index 6e2ae12..cc235b3 100644 --- a/src/tmux_utils.sh +++ b/src/tmux_utils.sh @@ -1,17 +1,47 @@ #!/bin/bash # get desired option from tmux or default -tmux_get_option() { - local _option _default_value - _option="$1" +tmux_get_option_or_default() { + local _option_name _default_value + _option_name="$1" _default_value="$2" - local _option_value - _option_value=$(tmux show-option -gqv "$_option") - if [ -z "$_option_value" ]; then - echo "$_default_value" + local _current_option_value + _current_option_value=$(tmux show-option -gqv "$_option_name") + if [[ -n "$_current_option_value" ]]; then + echo "$_current_option_value" else - echo "$_option_value" + echo "$_default_value" + fi +} + +# get desired tmux option or use given default value +tmux_get_option() { + local _option_name _default_value + _option_name="$1" + _default_value="$2" + + local _current_option_value + _current_option_value=$(tmux show-option -gqv "$_option_name") + if [[ -n "$_current_option_value" ]]; then + echo "$_current_option_value" + else + echo "$_default_value" + fi +} + +# get desired window-option from tmux or default +tmux_get_window_option() { + local _option_name _default_value + _option_name="$1" + _default_value="$2" + + local _current_option_value + _current_option_value=$(tmux show-window-option -gqv "$_option_name") + if [[ -n "$_current_option_value" ]]; then + echo "$_current_option_value" + else + echo "$_default_value" fi } @@ -21,8 +51,6 @@ tmux_append_seto() { _option="$1" _value="$2" TMUX_CMDS+=("set-option" "-gq" "${_option}" "${_value}" ";") - # _retult=("set-option -gq" "${_option}" "${_value}" ";") - # echo "${_retult[*]}" } # append preconfigured tmux set-window-option to global array @@ -31,6 +59,20 @@ tmux_append_setwo() { _option="$1" _value="$2" TMUX_CMDS+=("set-window-option" "-gq" "${_option}" "${_value}" ";") - # _retult=("set-window-option -gq" "${_option}" "${_value}" ";") - # echo "${_retult[*]}" +} + +# imediately execute tmux option +tmux_set_option_now() { + local _option_name _value + _option_name="$1" + _value="$2" + tmux set-option -gq "$_option_name" "$_value" +} + +# imediately execute tmux option +tmux_set_window_option_now() { + local _option_name _value + _option_name="$1" + _value="$2" + tmux set-window-option -gq "$_option_name" "$_value" } From a3f964c002e4a389afd2e742cd7bd18a0bca984f Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sun, 15 Sep 2024 00:43:53 +0200 Subject: [PATCH 04/10] fix: transparency for tabs in left status bar --- src/theme_gruvbox_dark256.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/theme_gruvbox_dark256.sh b/src/theme_gruvbox_dark256.sh index 0dcc014..d37a5b6 100644 --- a/src/theme_gruvbox_dark256.sh +++ b/src/theme_gruvbox_dark256.sh @@ -68,8 +68,12 @@ theme_set_dark_256() { tmux_append_seto "status-right" "#[bg=${_status_right_bg},fg=${col_bg2},nobold,nounderscore,noitalics]#[bg=${col_bg2},fg=${col_fg4}] ${_right_status_x}  ${_right_status_y} #[bg=${col_bg2},fg=${col_fg3},nobold,noitalics,nounderscore]#[bg=${col_fg3},fg=${col_bg1}] ${_right_status_z}" # current window - tmux_append_setwo "window-status-current-format" "#[bg=${col_yellow2},fg=${col_bg1},nobold,noitalics,nounderscore]#[bg=${col_yellow2},fg=${col_bg2}] #I #[bg=${col_yellow2},fg=${col_bg2},bold] #W#{?window_zoomed_flag,*Z,} #{?window_end_flag,#[bg=default],#[bg=colour237]}#[fg=${col_yellow2},nobold,noitalics,nounderscore]" + local _current_window_status_format_bg=${col_bg1} + if [[ "$_statusbar_alpha" == "true" ]]; then _current_window_status_format_bg="default"; fi + tmux_append_setwo "window-status-current-format" "#[bg=${col_yellow2},fg=${col_bg1},nobold,noitalics,nounderscore]#[bg=${col_yellow2},fg=${col_bg2}] #I #[bg=${col_yellow2},fg=${col_bg2},bold] #W#{?window_zoomed_flag,*Z,} #{?window_end_flag,#[bg=${_current_window_status_format_bg}],#[bg=${col_bg1}]}#[fg=${col_yellow2},nobold,noitalics,nounderscore]" # default window - tmux_append_setwo "window-status-format" "#[bg=${col_bg2},fg=${col_bg1},noitalics]#[bg=${col_bg2},fg=${col_fg1}] #I #[bg=${col_bg2},fg=${col_fg1}] #W #{?window_end_flag,#[bg=default],#[bg=colour237]}#[fg=${col_bg2},noitalics]" + local _default_window_status_format_bg=${col_bg1} + if [[ "$_statusbar_alpha" == "true" ]]; then _default_window_status_format_bg="default"; fi + tmux_append_setwo "window-status-format" "#[bg=${col_bg2},fg=${col_bg1},noitalics]#[bg=${col_bg2},fg=${col_fg1}] #I #[bg=${col_bg2},fg=${col_fg1}] #W #{?window_end_flag,#[bg=${_default_window_status_format_bg}],#[bg=${col_bg1}]}#[fg=${col_bg2},noitalics]" } From a8d87fa13b50711eeae22de0de1f9b3d910514fd Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sun, 15 Sep 2024 01:15:39 +0200 Subject: [PATCH 05/10] fix: shellcheck errors --- gruvbox-tpm.tmux | 1 + src/gruvbox-main.sh | 8 ++++++++ src/palette_gruvbox_dark.sh | 1 + src/palette_gruvbox_light.sh | 1 + src/theme_gruvbox_light256.sh | 5 ++++- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gruvbox-tpm.tmux b/gruvbox-tpm.tmux index b93207a..6d3946a 100755 --- a/gruvbox-tpm.tmux +++ b/gruvbox-tpm.tmux @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# shellcheck disable=SC1091 source "./src/gruvbox-main.sh" # vim: ai et ft=bash diff --git a/src/gruvbox-main.sh b/src/gruvbox-main.sh index 9701c08..bfde3cd 100755 --- a/src/gruvbox-main.sh +++ b/src/gruvbox-main.sh @@ -9,9 +9,13 @@ readonly CURRENT_DIR declate -a TMUX_CMDS # load libraries +# shellcheck disable=1091 source "${CURRENT_DIR}/src/helper_methods.sh" +# shellcheck disable=1091 source "${CURRENT_DIR}/src/tmux_utils.sh" +# shellcheck disable=1091 source "${CURRENT_DIR}/src/theme_gruvbox_dark256.sh" +# shellcheck disable=1091 source "${CURRENT_DIR}/src/theme_gruvbox_light256.sh" readonly TMUX_GRUVBOX="@tmux-gruvbox" @@ -40,11 +44,15 @@ main() { case "$_theme" in light | light256) + # shellcheck disable=1091 source "${CURRENT_DIR}/src/palette_gruvbox_light.sh" + # shellcheck disable=1091 source "${CURRENT_DIR}/src/theme_gruvbox_light256.sh" ;; dark | dark256 | *) + # shellcheck disable=1091 source "${CURRENT_DIR}/src/palette_gruvbox_dark.sh" + # shellcheck disable=1091 source "${CURRENT_DIR}/src/theme_gruvbox_dark256.sh" ;; esac diff --git a/src/palette_gruvbox_dark.sh b/src/palette_gruvbox_dark.sh index dc87b89..5470ee8 100644 --- a/src/palette_gruvbox_dark.sh +++ b/src/palette_gruvbox_dark.sh @@ -11,6 +11,7 @@ # # The names of colors used from https://github.com/morhetz/gruvbox +# shellcheck disable=2034 # ignored as this file only contains var definitions col_bg=colour235 col_bg0_h=colour234 col_bg0=colour235 diff --git a/src/palette_gruvbox_light.sh b/src/palette_gruvbox_light.sh index bf9b75f..3949472 100644 --- a/src/palette_gruvbox_light.sh +++ b/src/palette_gruvbox_light.sh @@ -11,6 +11,7 @@ # # The names of colors used from https://github.com/morhetz/gruvbox +# shellcheck disable=2034 # ignored as this file only contains var definitions col_bg=colour229 col_bg0_h=colour230 col_bg0=colour229 diff --git a/src/theme_gruvbox_light256.sh b/src/theme_gruvbox_light256.sh index aaa5246..eb15f90 100644 --- a/src/theme_gruvbox_light256.sh +++ b/src/theme_gruvbox_light256.sh @@ -1,6 +1,9 @@ #!/bin/bash -# themes may use different colors in sets therefore we setup dark and light separately +# Themes may use different colors in sets therefore we setup dark and light +# separately. +# +# shellcheck disable=SC2154 theme_set_light_256() { local _left_status_value _right_status_value _window_status_current_format _window_status_format _left_status_a=$1 From 44afa4e5a34f4a36d7c84ea02fd4adb45ca65ff1 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sun, 15 Sep 2024 01:38:24 +0200 Subject: [PATCH 06/10] fix: files according to shfmt --- src/gruvbox-main.sh | 82 ++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/gruvbox-main.sh b/src/gruvbox-main.sh index bfde3cd..5dbba7e 100755 --- a/src/gruvbox-main.sh +++ b/src/gruvbox-main.sh @@ -35,53 +35,53 @@ DEFAULT_RIGHT_STATUS_Y='%H:%M' DEFAULT_RIGHT_STATUS_Z='#h' main() { - TMUX_CMDS=() # clear + TMUX_CMDS=() # clear - # load proper palette for the theme asap to avoid additional variable interpolation - local _theme - _theme=$(tmux_get_option "${TMUX_GRUVBOX}" "${DEFAULT_THEME}") - _statusbar_alpha=$(tmux_get_option "${TMUX_GRUVBOX_STATUSBAR_ALPHA}" "${DEFAULT_STATUSBAR_ALPHA}") + # load proper palette for the theme asap to avoid additional variable interpolation + local _theme + _theme=$(tmux_get_option "${TMUX_GRUVBOX}" "${DEFAULT_THEME}") + _statusbar_alpha=$(tmux_get_option "${TMUX_GRUVBOX_STATUSBAR_ALPHA}" "${DEFAULT_STATUSBAR_ALPHA}") - case "$_theme" in - light | light256) - # shellcheck disable=1091 - source "${CURRENT_DIR}/src/palette_gruvbox_light.sh" - # shellcheck disable=1091 - source "${CURRENT_DIR}/src/theme_gruvbox_light256.sh" - ;; - dark | dark256 | *) - # shellcheck disable=1091 - source "${CURRENT_DIR}/src/palette_gruvbox_dark.sh" - # shellcheck disable=1091 - source "${CURRENT_DIR}/src/theme_gruvbox_dark256.sh" - ;; - esac + case "$_theme" in + light | light256) + # shellcheck disable=1091 + source "${CURRENT_DIR}/src/palette_gruvbox_light.sh" + # shellcheck disable=1091 + source "${CURRENT_DIR}/src/theme_gruvbox_light256.sh" + ;; + dark | dark256 | *) + # shellcheck disable=1091 + source "${CURRENT_DIR}/src/palette_gruvbox_dark.sh" + # shellcheck disable=1091 + source "${CURRENT_DIR}/src/theme_gruvbox_dark256.sh" + ;; + esac - local _status_left _status_right _window_status_current_format _window_status_format - _status_left_a=$(tmux_get_option "$TMUX_GRUVBOX_LEFT_STATUS_A" "$DEFAULT_LEFT_STATUS_A") - _status_right_x=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_X" "$DEFAULT_RIGHT_STATUS_X") - _status_right_y=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_Y" "$DEFAULT_RIGHT_STATUS_Y") - _status_right_z=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_Z" "$DEFAULT_RIGHT_STATUS_Z") + local _status_left _status_right _window_status_current_format _window_status_format + _status_left_a=$(tmux_get_option "$TMUX_GRUVBOX_LEFT_STATUS_A" "$DEFAULT_LEFT_STATUS_A") + _status_right_x=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_X" "$DEFAULT_RIGHT_STATUS_X") + _status_right_y=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_Y" "$DEFAULT_RIGHT_STATUS_Y") + _status_right_z=$(tmux_get_option "$TMUX_GRUVBOX_RIGHT_STAUTS_Z" "$DEFAULT_RIGHT_STATUS_Z") - theme_args=( - "$_status_left_a" - "$_status_right_x" - "$_status_right_y" - "$_status_right_z" - "$_statusbar_alpha" - ) + theme_args=( + "$_status_left_a" + "$_status_right_x" + "$_status_right_y" + "$_status_right_z" + "$_statusbar_alpha" + ) - case $_theme in - light | light256) - theme_set_light_256 "${theme_args[@]}" - ;; - dark | dark256 | *) - theme_set_dark_256 "${theme_args[@]}" - ;; - esac + case $_theme in + light | light256) + theme_set_light_256 "${theme_args[@]}" + ;; + dark | dark256 | *) + theme_set_dark_256 "${theme_args[@]}" + ;; + esac - # execute commands with tmux as array of options - tmux "${TMUX_CMDS[@]}" + # execute commands with tmux as array of options + tmux "${TMUX_CMDS[@]}" } main "$@" From 3161b7834c7e010c81aac960d21c774e291f0b28 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sun, 15 Sep 2024 01:42:51 +0200 Subject: [PATCH 07/10] feat: remove unnecessary modeline --- src/gruvbox-main.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gruvbox-main.sh b/src/gruvbox-main.sh index 5dbba7e..e1369ba 100755 --- a/src/gruvbox-main.sh +++ b/src/gruvbox-main.sh @@ -85,5 +85,3 @@ main() { } main "$@" - -# vi: ft=bash From fec8ecdca4bddfb222d781b1d06f85aab3e882bc Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sun, 15 Sep 2024 01:51:00 +0200 Subject: [PATCH 08/10] feat: save palettes as 256 color --- src/{palette_gruvbox_dark.sh => palette_gruvbox_dark256.sh} | 0 src/{palette_gruvbox_light.sh => palette_gruvbox_light256.sh} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/{palette_gruvbox_dark.sh => palette_gruvbox_dark256.sh} (100%) rename src/{palette_gruvbox_light.sh => palette_gruvbox_light256.sh} (100%) diff --git a/src/palette_gruvbox_dark.sh b/src/palette_gruvbox_dark256.sh similarity index 100% rename from src/palette_gruvbox_dark.sh rename to src/palette_gruvbox_dark256.sh diff --git a/src/palette_gruvbox_light.sh b/src/palette_gruvbox_light256.sh similarity index 100% rename from src/palette_gruvbox_light.sh rename to src/palette_gruvbox_light256.sh From 4a5d510c156dd53ba6897d263331cbe30ae60c47 Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Sun, 15 Sep 2024 22:23:01 +0200 Subject: [PATCH 09/10] feat: update information about dark256 & light256 themes --- README.md | 117 ++++++++++++++---- src/gruvbox-main.sh | 16 +-- ...uvbox_dark256.sh => theme_gruvbox_dark.sh} | 2 +- ...box_light256.sh => theme_gruvbox_light.sh} | 2 +- 4 files changed, 100 insertions(+), 37 deletions(-) rename src/{theme_gruvbox_dark256.sh => theme_gruvbox_dark.sh} (99%) rename src/{theme_gruvbox_light256.sh => theme_gruvbox_light.sh} (99%) diff --git a/README.md b/README.md index ff5426d..eb2da52 100644 --- a/README.md +++ b/README.md @@ -25,60 +25,126 @@ Theme with 'retro groove' flavor for [Tmux][github-tmux], based on Pavel Pertsev ## Installation -**Available Themes** +### Install via [TPM][github-tpm] (recommended) -- [`dark`](./docs/assets/img/gruvbox-dark-theme.png) -- [`light`](./docs/assets/img/gruvbox-light-theme.png) -- `dark-transparent` (experimental) -- `light-transparent` (experimental) - -### Install manually - -The simplest way is just: - -> [!TIP] -> Always make a backup of your config files before any action. - -```bash -cat tmux-gruvbox-dark.conf >> ~/.tmux.conf -``` - -### Install through [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) - -Add plugin to the list of TPM plugins in `.tmux.conf` and select desired theme. +Add plugin at the top list of TPM plugins in `.tmux.conf` and select desired theme. ```bash +# ~/.tmux.conf set -g @plugin 'egel/tmux-gruvbox' -set -g @tmux-gruvbox 'dark' # or 'light', 'dark-transparent', 'light-transparent' +# set desired options... +set -g @tmux-gruvbox 'dark' # or 'light' ``` Hit `prefix + I` to fetch the plugin and source it. Your Tmux should be updated with the theme at this point. +### Install manually + +1. Clone the project to desired location + + > ![TIP] If you do not have github account [download](https://github.com/egel/tmux-gruvbox/archive/refs/heads/main.zip) it and unzip. + + ```bash + cd ~/projects/ + git clone ... + ``` + +1. Add theme at to top of your `~/.tmux.conf` config. + + ```bash + # ~/.tmux.conf + run ~/projects/tmux-gruvbox/tmux-gruvbox.tmux + # set desired options... + set -g @tmux-gruvbox 'dark' # or light + ``` + +## Configuration options + +### Theme + +- default value: `dark256` +- available themes: + - [`dark256`](./docs/assets/img/gruvbox-dark-theme.png) + - [`light256`](./docs/assets/img/gruvbox-light-theme.png) + +```bash +set -g @tmux-gruvbox 'dark256' +``` + +### Transparent status-bar + +- default value: `'false'` +- tmux >= 3.2 (experimental) + +```bash +set -g @tmux-gruvbox-statusbar-alpha 'true' +``` + +### Left Status (Section A) + +- default value: `'#S'` + +```bash +set -g @tmux-gruvbox-left-status-a +``` + +### Right Status (Section X) + +- default value: `'%Y-%m-%d'` + +This section is customizable for user, and by default contains current date. + +```bash +set -g @tmux-gruvbox-right-status-x +``` + +### Right Status (Section Y) + +- default value: `'%H:%M'` + +This section is customizable for user, and by default contains current time. + +```bash +# set different time format +set -g @tmux-gruvbox-right-status-y '%H:%M' +``` + +### Right Status (Section Z) + +- default value: `'#h'` + +This section is customizable for user, and by default contains hostname. + +```bash +# enhance this section with other plugin +set -g @tmux-gruvbox-right-status-z '#h #{tmux_mode_indicator} ' +``` + ## Development To run project locally: -1. clone the repo to desired place +1. clone the repository to desired place ```bash cd $HOME/projects/ git clone ... ``` -1. create symlink in plugin dir to the cloned repo: +1. create a symlink to the cloned repository (best in the standard [TPM][github-tpm] plugin directory): ```bash # cd to tmux plugin directory cd ~/.tmux/plugins/ - # create simlink to cloned repo + # create symlink to cloned repo ln -sf $HOME/projects/tmux-gruvbox/ tmux-gruvbox ``` 1. and in `~/.tmux.conf` set ```bash - # add plugin + # ~/.tmux.conf set -g @plugin 'egel/tmux-gruvbox' # set desired options... set -g @tmux-gruvbox 'dark' @@ -101,6 +167,7 @@ GPLv3 - Maciej Sypień [github-hack]: https://github.com/chrissimpkins/Hack [github-nerd-fonts]: https://github.com/ryanoasis/nerd-fonts [github-alacritty]: https://github.com/alacritty/alacritty +[github-tpm]: https://github.com/tmux-plugins/tpm [tmux-color-solarized]: https://github.com/seebi/tmux-colors-solarized [pexcel-1]: https://www.pexels.com/photo/urban-photo-of-an-alley-2411688/ [pexcel-2]: https://www.pexels.com/photo/lights-hanging-above-the-alley-in-a-city-at-night-27044195/ diff --git a/src/gruvbox-main.sh b/src/gruvbox-main.sh index e1369ba..f63b218 100755 --- a/src/gruvbox-main.sh +++ b/src/gruvbox-main.sh @@ -13,10 +13,6 @@ declate -a TMUX_CMDS source "${CURRENT_DIR}/src/helper_methods.sh" # shellcheck disable=1091 source "${CURRENT_DIR}/src/tmux_utils.sh" -# shellcheck disable=1091 -source "${CURRENT_DIR}/src/theme_gruvbox_dark256.sh" -# shellcheck disable=1091 -source "${CURRENT_DIR}/src/theme_gruvbox_light256.sh" readonly TMUX_GRUVBOX="@tmux-gruvbox" readonly TMUX_GRUVBOX_STATUSBAR_ALPHA="@tmux-gruvbox-statusbar-alpha" @@ -45,15 +41,15 @@ main() { case "$_theme" in light | light256) # shellcheck disable=1091 - source "${CURRENT_DIR}/src/palette_gruvbox_light.sh" + source "${CURRENT_DIR}/src/palette_gruvbox_light256.sh" # shellcheck disable=1091 - source "${CURRENT_DIR}/src/theme_gruvbox_light256.sh" + source "${CURRENT_DIR}/src/theme_gruvbox_light.sh" ;; dark | dark256 | *) # shellcheck disable=1091 - source "${CURRENT_DIR}/src/palette_gruvbox_dark.sh" + source "${CURRENT_DIR}/src/palette_gruvbox_dark256.sh" # shellcheck disable=1091 - source "${CURRENT_DIR}/src/theme_gruvbox_dark256.sh" + source "${CURRENT_DIR}/src/theme_gruvbox_dark.sh" ;; esac @@ -73,10 +69,10 @@ main() { case $_theme in light | light256) - theme_set_light_256 "${theme_args[@]}" + theme_set_light "${theme_args[@]}" ;; dark | dark256 | *) - theme_set_dark_256 "${theme_args[@]}" + theme_set_dark "${theme_args[@]}" ;; esac diff --git a/src/theme_gruvbox_dark256.sh b/src/theme_gruvbox_dark.sh similarity index 99% rename from src/theme_gruvbox_dark256.sh rename to src/theme_gruvbox_dark.sh index d37a5b6..3ee9e88 100644 --- a/src/theme_gruvbox_dark256.sh +++ b/src/theme_gruvbox_dark.sh @@ -4,7 +4,7 @@ # separately. # # shellcheck disable=SC2154 -theme_set_dark_256() { +theme_set_dark() { local _left_status_a _right_status_x _right_status_y _right_status_z _statusbar_alpha _left_status_a=$1 _right_status_x=$2 diff --git a/src/theme_gruvbox_light256.sh b/src/theme_gruvbox_light.sh similarity index 99% rename from src/theme_gruvbox_light256.sh rename to src/theme_gruvbox_light.sh index eb15f90..f5c21fd 100644 --- a/src/theme_gruvbox_light256.sh +++ b/src/theme_gruvbox_light.sh @@ -4,7 +4,7 @@ # separately. # # shellcheck disable=SC2154 -theme_set_light_256() { +theme_set_light() { local _left_status_value _right_status_value _window_status_current_format _window_status_format _left_status_a=$1 _right_status_x=$2 From f2de4db0ec829332ead9d968ab2debf70091604a Mon Sep 17 00:00:00 2001 From: Maciej Sypien Date: Mon, 16 Sep 2024 00:41:42 +0200 Subject: [PATCH 10/10] chore: add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7a6751..33f22de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added light and dark transparent themes [#18](https://github.com/egel/tmux-gruvbox/issues/18) - Added editorconfig - Added code linters for shellcheck & shfmt [#33](https://github.com/egel/tmux-gruvbox/issues/33) +- Added customizable statusbar [#31](https://github.com/egel/tmux-gruvbox/issues/31) ### Changed