From e2b380a768a87378c623746890a9edbd1d80376a Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Wed, 23 Nov 2022 19:32:19 -0500 Subject: [PATCH] Refactor the theme selection; So the idea here is that the themes are only different based on the variables for the theme files. So this will change the theme variables to have `local` prefixes to keep the namespace regular. I decided to keep this like this until I get more feedback, because I think I could also just manually add the local to everything in the old `tmuxtheme` files. I chose this though because I really like how the `catppuccin-selected-theme` can be used for local debugging or testing out new colors if things were ever to need to be changed. If what that `sed` and `source` command is doing is unclear, I can do better about commenting around it. --- catppuccin-frappe.tmuxtheme | 54 ------------- catppuccin-latte.tmuxtheme | 54 ------------- catppuccin-macchiato.tmuxtheme | 54 ------------- catppuccin-mocha.tmuxtheme | 63 --------------- catppuccin.tmux | 137 +++++++++++++++++++++++++++++---- 5 files changed, 120 insertions(+), 242 deletions(-) mode change 100755 => 100644 catppuccin-frappe.tmuxtheme mode change 100755 => 100644 catppuccin-latte.tmuxtheme mode change 100755 => 100644 catppuccin-macchiato.tmuxtheme mode change 100755 => 100644 catppuccin-mocha.tmuxtheme diff --git a/catppuccin-frappe.tmuxtheme b/catppuccin-frappe.tmuxtheme old mode 100755 new mode 100644 index 8ed37a8..a38a73f --- a/catppuccin-frappe.tmuxtheme +++ b/catppuccin-frappe.tmuxtheme @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - # NOTE: you can use vars with $ and ${} as long as the str is double quoted: "" # WARNING: hex colors can't contain capital letters @@ -17,55 +15,3 @@ thm_yellow="#e5c890" thm_blue="#8caaee" thm_orange="#ef9f76" thm_black4="#626880" - -# ----------------------------=== Theme ===-------------------------- - -# utils -set() { - local option=$1 - local value=$2 - tmux set-option -gq "$option" "$value" -} - -setw() { - local option=$1 - local value=$2 - tmux set-window-option -gq "$option" "$value" -} - -# status -set status "on" -set status-bg "${thm_bg}" -set status-justify "left" -set status-left-length "100" -set status-right-length "100" - -# messages -set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" -set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" - -# panes -set pane-border-style "fg=${thm_gray}" -set pane-active-border-style "fg=${thm_blue}" - -# windows -setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" -setw window-status-separator "" -setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" - -# --------=== Statusline - -set status-left "" -set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] #[fg=$thm_fg,bg=$thm_gray] #S " - -# current_dir -setw window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " -setw window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " - -# parent_dir/current_dir -# setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " -# setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " - -# --------=== Modes -setw clock-mode-colour "${thm_blue}" -setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" diff --git a/catppuccin-latte.tmuxtheme b/catppuccin-latte.tmuxtheme old mode 100755 new mode 100644 index 1ddb188..16f078f --- a/catppuccin-latte.tmuxtheme +++ b/catppuccin-latte.tmuxtheme @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - # NOTE: you can use vars with $ and ${} as long as the str is double quoted: "" # WARNING: hex colors can't contain capital letters @@ -17,55 +15,3 @@ thm_yellow="#df8e1d" thm_blue="#1e66f5" thm_orange="#fe640b" thm_black4="#acb0be" - -# ----------------------------=== Theme ===-------------------------- - -# utils -set() { - local option=$1 - local value=$2 - tmux set-option -gq "$option" "$value" -} - -setw() { - local option=$1 - local value=$2 - tmux set-window-option -gq "$option" "$value" -} - -# status -set status "on" -set status-bg "${thm_bg}" -set status-justify "left" -set status-left-length "100" -set status-right-length "100" - -# messages -set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" -set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" - -# panes -set pane-border-style "fg=${thm_gray}" -set pane-active-border-style "fg=${thm_blue}" - -# windows -setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" -setw window-status-separator "" -setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" - -# --------=== Statusline - -set status-left "" -set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] #[fg=$thm_fg,bg=$thm_gray] #S " - -# current_dir -setw window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " -setw window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " - -# parent_dir/current_dir -# setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " -# setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " - -# --------=== Modes -setw clock-mode-colour "${thm_blue}" -setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" diff --git a/catppuccin-macchiato.tmuxtheme b/catppuccin-macchiato.tmuxtheme old mode 100755 new mode 100644 index 3b76e74..c90bf76 --- a/catppuccin-macchiato.tmuxtheme +++ b/catppuccin-macchiato.tmuxtheme @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - # NOTE: you can use vars with $ and ${} as long as the str is double quoted: "" # WARNING: hex colors can't contain capital letters @@ -17,55 +15,3 @@ thm_yellow="#eed49f" thm_blue="#8aadf4" thm_orange="#f5a97f" thm_black4="#5b6078" - -# ----------------------------=== Theme ===-------------------------- - -# utils -set() { - local option=$1 - local value=$2 - tmux set-option -gq "$option" "$value" -} - -setw() { - local option=$1 - local value=$2 - tmux set-window-option -gq "$option" "$value" -} - -# status -set status "on" -set status-bg "${thm_bg}" -set status-justify "left" -set status-left-length "100" -set status-right-length "100" - -# messages -set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" -set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" - -# panes -set pane-border-style "fg=${thm_gray}" -set pane-active-border-style "fg=${thm_blue}" - -# windows -setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" -setw window-status-separator "" -setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" - -# --------=== Statusline - -set status-left "" -set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] #[fg=$thm_fg,bg=$thm_gray] #S " - -# current_dir -setw window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " -setw window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " - -# parent_dir/current_dir -# setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " -# setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " - -# --------=== Modes -setw clock-mode-colour "${thm_blue}" -setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" diff --git a/catppuccin-mocha.tmuxtheme b/catppuccin-mocha.tmuxtheme old mode 100755 new mode 100644 index 85a95db..41e6369 --- a/catppuccin-mocha.tmuxtheme +++ b/catppuccin-mocha.tmuxtheme @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - # NOTE: you can use vars with $ and ${} as long as the str is double quoted: "" # WARNING: hex colors can't contain capital letters @@ -17,64 +15,3 @@ thm_yellow="#f9e2af" thm_blue="#89b4fa" thm_orange="#fab387" thm_black4="#585b70" - -# ----------------------------=== Theme ===-------------------------- - -# utils -set() { - local option=$1 - local value=$2 - tmux set-option -gq "$option" "$value" -} - -setw() { - local option=$1 - local value=$2 - tmux set-window-option -gq "$option" "$value" -} - -# status -set status "on" -set status-bg "${thm_bg}" -set status-justify "left" -set status-left-length "100" -set status-right-length "100" - -# messages -set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" -set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" - -# panes -set pane-border-style "fg=${thm_gray}" -set pane-active-border-style "fg=${thm_blue}" - -# windows -setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" -setw window-status-separator "" -setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" - -# TODO: continue implementing this later today... -wt_enabled=$(tmux show -gqv @catppuccin_window_tabs_enabled) - -status_left="" -if [[ "${wt_enabled}" == "on" ]] -then - status_left="window_tabs_enabled" -fi - -# --------=== Statusline - -set status-left "#[fg=$thm_red,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left#[fg=$thm_fg,bg=$thm_bg,nobold,nounderscore,noitalics]" -set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] #[fg=$thm_fg,bg=$thm_gray] #S " - -# current_dir -setw window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " -setw window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " - -# parent_dir/current_dir -# setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " -# setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " - -# --------=== Modes -setw clock-mode-colour "${thm_blue}" -setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" diff --git a/catppuccin.tmux b/catppuccin.tmux index 75fe64c..6b4dda0 100755 --- a/catppuccin.tmux +++ b/catppuccin.tmux @@ -1,27 +1,130 @@ #!/usr/bin/env bash CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -get-tmux-option() { - local option value default - option="$1" - default="$2" - value="$(tmux show-option -gqv "$option")" - - if [ -n "$value" ]; then - echo "$value" - else - # README: Set the default option if it's not set originally. - tmux set-option -gq "${option}" "${default}" - echo "$default" - fi -} - main() { + # TODO: This function works great in here, but I'd like also like for it to set + # the option to the default if it's not set too. I'll get to it soon. + get-tmux-option() { + local option value default + option="$1" + default="$2" + value="$(tmux show-option -gqv "$option")" + + if [ -n "$value" ]; then + echo "$value" + else + # README: Set the default option if it's not set originally. + tmux set-option -gq "${option}" "${default}" + echo "$default" + fi + } + + set() { + local option=$1 + local value=$2 + tmux set-option -gq "$option" "$value" + } + + setw() { + local option=$1 + local value=$2 + tmux set-window-option -gq "$option" "$value" + } + local theme local window_tabs_enabled theme="$(get-tmux-option "@catppuccin_flavour" "mocha")" - window_tabs_enabled="$(get-tmux-option "@catppuccin_window_tabs_enabled" "false")" - tmux run -b "$CURRENT_DIR/catppuccin-${theme}.tmuxtheme" + window_tabs_enabled="$(get-tmux-option "@catppuccin_window_tabs_enabled" "off")" + + # NOTE: Pulling in the selected theme by the theme that's being set as local + # variables. + sed -E 's/^(.+=)/local \1/' \ + > catppuccin-selected-theme.tmuxtheme \ + < "${CURRENT_DIR}/catppuccin-${theme}.tmuxtheme" + + source catppuccin-selected-theme.tmuxtheme + + # status + set status "on" + set status-bg "${thm_bg}" + set status-justify "left" + set status-left-length "100" + set status-right-length "100" + + # messages + set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + + # panes + set pane-border-style "fg=${thm_gray}" + set pane-active-border-style "fg=${thm_blue}" + + # windows + setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" + setw window-status-separator "" + setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" + + # --------=== Statusline + + set status-left "" + set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] #[fg=$thm_fg,bg=$thm_gray] #S " + + # current_dir + setw window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " + setw window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " + + # parent_dir/current_dir + # setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " + # setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " + + # --------=== Modes + setw clock-mode-colour "${thm_blue}" + setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" + + # set status "on" + # set status-bg "${thm_bg}" + # set status-justify "left" + # set status-left-length "100" + # set status-right-length "100" + # + # # messages + # set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + # set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + # + # # panes + # set pane-border-style "fg=${thm_gray}" + # set pane-active-border-style "fg=${thm_blue}" + # + # # windows + # setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" + # setw window-status-separator "" + # setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" + # + # # --------=== Statusline + # + # # TODO: continue implementing this later today... + # wt_enabled=$(tmux show -gqv @catppuccin_window_tabs_enabled) + # + # status_left="" + # if [[ "${wt_enabled}" == "on" ]] + # then + # status_left="window_tabs_enabled" + # fi + # + # set status-left "#[fg=$thm_red,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left#[fg=$thm_fg,bg=$thm_bg,nobold,nounderscore,noitalics]" + # set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #[fg=$thm_fg,bg=$thm_gray] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] #[fg=$thm_fg,bg=$thm_gray] #S " + # + # # current_dir + # setw window-status-format "#[fg=$thm_fg,bg=$thm_bg] #W #[fg=$thm_bg,bg=$thm_blue] #I#[fg=$thm_blue,bg=$thm_bg]#[fg=$thm_fg,bg=$thm_bg,nobold,nounderscore,noitalics] " + # setw window-status-current-format "#[fg=$thm_fg,bg=$thm_gray] #W #[fg=$thm_bg,bg=$thm_orange] #I#[fg=$thm_orange,bg=$thm_bg]#[fg=$thm_fg,bg=$thm_bg,nobold,nounderscore,noitalics] " + # + # # parent_dir/current_dir + # # setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " + # # setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " + # + # # --------=== Modes + # setw clock-mode-colour "${thm_blue}" + # setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" } main "$@"