feat: add customizable statusbar (#31)
* feat: define dark and light color palettes * feat: add customization of status-right & status-left sections * feat: rename to gruvbox_dark256 and implement alpha option * fix: transparency for tabs in left status bar * fix: shellcheck errors * fix: files according to shfmt * feat: remove unnecessary modeline * feat: save palettes as 256 color * feat: update information about dark256 & light256 themes * chore: add changelog entry
This commit is contained in:
parent
f01574b318
commit
4f8b69ab8b
10 changed files with 487 additions and 48 deletions
|
@ -5,37 +5,79 @@ readonly CURRENT_DIR
|
|||
readonly THEME_OPTION="@tmux-gruvbox"
|
||||
readonly DEFAULT_THEME="dark"
|
||||
|
||||
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
|
||||
# shellcheck disable=1091
|
||||
source "${CURRENT_DIR}/src/helper_methods.sh"
|
||||
# shellcheck disable=1091
|
||||
source "${CURRENT_DIR}/src/tmux_utils.sh"
|
||||
|
||||
readonly TMUX_GRUVBOX="@tmux-gruvbox"
|
||||
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 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 _path
|
||||
_theme=$(get_theme "$THEME_OPTION" "$DEFAULT_THEME")
|
||||
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}")
|
||||
|
||||
case "$_theme" in
|
||||
light-transparent)
|
||||
_theme="light-transparent"
|
||||
;;
|
||||
dark-transparent)
|
||||
_theme="dark-transparent"
|
||||
;;
|
||||
light | light256)
|
||||
_theme="light"
|
||||
# shellcheck disable=1091
|
||||
source "${CURRENT_DIR}/src/palette_gruvbox_light256.sh"
|
||||
# shellcheck disable=1091
|
||||
source "${CURRENT_DIR}/src/theme_gruvbox_light.sh"
|
||||
;;
|
||||
dark | dark256 | *)
|
||||
_theme="dark"
|
||||
# shellcheck disable=1091
|
||||
source "${CURRENT_DIR}/src/palette_gruvbox_dark256.sh"
|
||||
# shellcheck disable=1091
|
||||
source "${CURRENT_DIR}/src/theme_gruvbox_dark.sh"
|
||||
;;
|
||||
esac
|
||||
|
||||
tmux source-file "${CURRENT_DIR}/tmux-gruvbox-${_theme}.conf"
|
||||
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"
|
||||
)
|
||||
|
||||
case $_theme in
|
||||
light | light256)
|
||||
theme_set_light "${theme_args[@]}"
|
||||
;;
|
||||
dark | dark256 | *)
|
||||
theme_set_dark "${theme_args[@]}"
|
||||
;;
|
||||
esac
|
||||
|
||||
# execute commands with tmux as array of options
|
||||
tmux "${TMUX_CMDS[@]}"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue