From 3b4bf404dbe435a31665cd721fb8d3d9b93b83e8 Mon Sep 17 00:00:00 2001 From: Valentin Uveges Date: Tue, 8 Aug 2023 11:45:45 +0300 Subject: [PATCH] feat(modules): refactor modules and extract common functionality --- catppuccin.tmux | 48 ++++++++++++++++---- src/default.conf | 11 ----- src/no-patched-fonts-status-line.conf | 29 ------------ src/pill-status-line.conf | 29 ------------ src/powerline-icons-status-line.conf | 30 ------------- src/powerline-status-line.conf | 29 ------------ status/application.sh | 16 +++---- status/date_time.sh | 19 +++----- status/directory.sh | 16 +++---- status/host.sh | 16 +++---- status/session.sh | 18 ++++++-- status/user.sh | 16 +++---- window/application_in_window.sh | 37 --------------- window/application_in_window_current.sh | 40 ----------------- window/directory_in_window.sh | 38 ---------------- window/directory_in_window_current.sh | 41 ----------------- window/window_current_format.sh | 60 +++++++++++++++++++++++++ window/window_format.sh | 59 ++++++++++++++++++++++++ 18 files changed, 200 insertions(+), 352 deletions(-) delete mode 100644 src/default.conf delete mode 100644 src/no-patched-fonts-status-line.conf delete mode 100644 src/pill-status-line.conf delete mode 100644 src/powerline-icons-status-line.conf delete mode 100644 src/powerline-status-line.conf delete mode 100644 window/application_in_window.sh delete mode 100644 window/application_in_window_current.sh delete mode 100644 window/directory_in_window.sh delete mode 100644 window/directory_in_window_current.sh create mode 100644 window/window_current_format.sh create mode 100644 window/window_format.sh diff --git a/catppuccin.tmux b/catppuccin.tmux index 4d8b787..b57de8d 100755 --- a/catppuccin.tmux +++ b/catppuccin.tmux @@ -31,6 +31,39 @@ setw() { tmux_commands+=(set-window-option -gq "$option" "$value" ";") } + +build_status_module() { + local index=$1 + local icon="$2" + local color="$3" + local text="$4" + + if [[ $index -eq 0 || $status_connect_separator == "no" ]] + then + local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" + else + local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" + fi + + if [[ $status_color_fill == "icon" ]] + then + local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon " + local show_text="#[fg=$thm_fg,bg=$thm_gray] $text" + local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" + fi + + if [[ $status_color_fill == "all" ]] + then + local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon " + local show_text="#[fg=$thm_bg,bg=$color]$text" + local show_right_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" + fi + + + echo "$show_left_separator$show_icon$show_text$show_right_separator" + +} + load_modules() { local loaded_modules @@ -95,21 +128,20 @@ main() { local window_left_separator="$(get_tmux_option "@catppuccin_window_left_separator" "█")" local window_right_separator="$(get_tmux_option "@catppuccin_window_right_separator" "█")" local window_middle_separator="$(get_tmux_option "@catppuccin_window_middle_separator" "█")" - local window_color_fill="$(get_tmux_option "@catppuccin_window_color_fill" "number")" - local window_icon_position="$(get_tmux_option "@catppuccin_window_icon_position" "right")" + local window_color_fill="$(get_tmux_option "@catppuccin_window_color_fill" "number")" # number, all + local window_icon_position="$(get_tmux_option "@catppuccin_window_icon_position" "right")" # right, left + local window_format_style="$(get_tmux_option "@catppuccin_window_format_style" "directory")" # directory, application - local window_module="$(get_tmux_option "@catppuccin_window_module" "directory_in_window")" - local window_current_module="$(get_tmux_option "@catppuccin_window_current_module" "directory_in_window_current")" - - local window_format=$( load_modules "$PLUGIN_DIR/window" "$window_module") - local window_current_format=$( load_modules "$PLUGIN_DIR/window" "$window_current_module") + local window_format=$( load_modules "$PLUGIN_DIR/window" "window_format") + local window_current_format=$( load_modules "$PLUGIN_DIR/window" "window_current_format") setw window-status-format "${window_format}" setw window-status-current-format "${window_current_format}" - local status_left_separator="$(get_tmux_option "@catppuccin_status_left_separator" " ")" + local status_left_separator="$(get_tmux_option "@catppuccin_status_left_separator" "")" local status_right_separator="$(get_tmux_option "@catppuccin_status_right_separator" "█")" local status_connect_separator="$(get_tmux_option "@catppuccin_status_connect_separator" "yes")" + local status_color_fill="$(get_tmux_option "@catppuccin_status_color_fill" "icon")" local status_modules="$(get_tmux_option "@catppuccin_status_modules" "application session")" local loaded_modules=$( load_modules "$PLUGIN_DIR/status" "$status_modules") diff --git a/src/default.conf b/src/default.conf deleted file mode 100644 index caa46bd..0000000 --- a/src/default.conf +++ /dev/null @@ -1,11 +0,0 @@ -local show_directory_in_window_status -readonly show_directory_in_window_status="#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " - -local show_directory_in_window_status_current -readonly show_directory_in_window_status_current="#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " - -local show_window_in_window_status -readonly show_window_in_window_status="#[fg=$thm_fg,bg=$thm_bg] #W #[fg=$thm_bg,bg=$thm_blue] #I#[fg=$thm_blue,bg=$thm_bg]$l_right_separator " - -local show_window_in_window_status_current -readonly show_window_in_window_status_current="#[fg=$thm_fg,bg=$thm_gray] #W #[fg=$thm_bg,bg=$thm_orange] #I#[fg=$thm_orange,bg=$thm_bg,nobold,nounderscore,noitalics]$l_right_separator " diff --git a/src/no-patched-fonts-status-line.conf b/src/no-patched-fonts-status-line.conf deleted file mode 100644 index c3cfdd8..0000000 --- a/src/no-patched-fonts-status-line.conf +++ /dev/null @@ -1,29 +0,0 @@ -local show_directory -readonly show_directory="#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #{b:pane_current_path} #[bg=$thm_bg] " - -local show_window -readonly show_window="#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #W #[bg=$thm_bg] " - -local show_session -readonly show_session="#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] #S #[bg=$thm_bg] " - -local show_directory_in_window_status -readonly show_directory_in_window_status="#[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics] #I #[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics] #{b:pane_current_path} " - -local show_directory_in_window_status_current -readonly show_directory_in_window_status_current="#[fg=$thm_bg,bg=$thm_orange,nobold,nounderscore,noitalics] #I #[fg=$thm_fg,bg=$thm_bg,nobold,nounderscore,noitalics] #{b:pane_current_path} " - -local show_window_in_window_status -readonly show_window_in_window_status="#[fg=$thm_fg,bg=$thm_bg,nobold,nounderscore,noitalics] #W #[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics] #I " - -local show_window_in_window_status_current -readonly show_window_in_window_status_current="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics] #W #[fg=$thm_bg,bg=$thm_orange,nobold,nounderscore,noitalics] #I " - -local show_user -readonly show_user="#[fg=$thm_bg,bg=$thm_cyan,nobold,nounderscore,noitalics] #(whoami) #[bg=$thm_bg] " - -local show_host -readonly show_host="#[fg=$thm_bg,bg=$thm_magenta,nobold,nounderscore,noitalics] #H #[bg=$thm_bg] " - -local show_date_time -readonly show_date_time="#[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics] $date_time #[bg=$thm_bg] " diff --git a/src/pill-status-line.conf b/src/pill-status-line.conf deleted file mode 100644 index d2b84a4..0000000 --- a/src/pill-status-line.conf +++ /dev/null @@ -1,29 +0,0 @@ -local show_directory -readonly show_directory="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics]$directory_icon #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} #[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$r_right_separator " - -local show_window -readonly show_window="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics]$window_icon #[fg=$thm_fg,bg=$thm_gray] #W #[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$r_right_separator " - -local show_session -readonly show_session="#[fg=$thm_green,bg=$thm_bg,nobold,nounderscore,noitalics]#{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}$r_left_separator#[fg=$thm_bg,bg=$thm_green]#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}$session_icon #[fg=$thm_fg,bg=$thm_gray] #S #[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$r_right_separator " - -local show_directory_in_window_status -readonly show_directory_in_window_status="#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " - -local show_directory_in_window_status_current -readonly show_directory_in_window_status_current="#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " - -local show_window_in_window_status -readonly show_window_in_window_status="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$l_left_separator#[fg=$thm_fg,bg=$thm_gray]#W #[fg=$thm_bg,bg=$thm_blue] #I#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$l_right_separator " - -local show_window_in_window_status_current -readonly show_window_in_window_status_current="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$l_left_separator#[fg=$thm_fg,bg=$thm_gray]#W #[fg=$thm_bg,bg=$thm_orange] #I#[fg=$thm_orange,bg=$thm_bg,nobold,nounderscore,noitalics]$l_right_separator " - -local show_user -readonly show_user="#[fg=$thm_cyan,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_cyan,nobold,nounderscore,noitalics]$user_icon #[fg=$thm_fg,bg=$thm_gray] #(whoami) #[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$r_right_separator " - -local show_host -readonly show_host="#[fg=$thm_magenta,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_magenta,nobold,nounderscore,noitalics]$host_icon #[fg=$thm_fg,bg=$thm_gray] #H #[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$r_right_separator " - -local show_date_time -readonly show_date_time="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics]$datetime_icon #[fg=$thm_fg,bg=$thm_gray] $date_time #[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$r_right_separator " diff --git a/src/powerline-icons-status-line.conf b/src/powerline-icons-status-line.conf deleted file mode 100644 index 479f6ce..0000000 --- a/src/powerline-icons-status-line.conf +++ /dev/null @@ -1,30 +0,0 @@ -local show_directory -readonly show_directory="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] $directory_icon #{b:pane_current_path} $r_right_separator" - -local show_window -readonly show_window="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] $window_icon #W $r_right_separator" - -local show_session -readonly show_session="#[fg=$thm_green,bg=$thm_bg,nobold,nounderscore,noitalics]#{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}$r_left_separator#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] $session_icon #S #{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg]$r_right_separator" - -local show_directory_in_window_status -readonly show_directory_in_window_status="#[fg=$thm_bg,bg=$thm_gray,nobold,noitalics,nounderscore]$l_left_separator #[fg=$thm_fg,bg=$thm_gray,nobold,noitalics,nounderscore]#I  #{b:pane_current_path} #[fg=$thm_gray,bg=$thm_bg,nobold,noitalics,nounderscore]$l_right_separator" - -local show_directory_in_window_status_current -readonly show_directory_in_window_status_current="#[fg=$thm_bg,bg=$thm_blue,nobold,noitalics,nounderscore]$l_left_separator #[fg=$thm_bg,bg=$thm_blue,nobold,noitalics,nounderscore]#I  #{b:pane_current_path} #[fg=$thm_blue,bg=$thm_bg,nobold,noitalics,nounderscore]$l_right_separator" - -local show_window_in_window_status -readonly show_window_in_window_status="#[fg=$thm_bg,bg=$thm_gray,nobold,noitalics,nounderscore]$l_left_separator #[fg=$thm_fg,bg=$thm_gray,nobold,noitalics,nounderscore]#W  #I #[fg=$thm_gray,bg=$thm_bg,nobold,noitalics,nounderscore]$l_right_separator" - -local show_window_in_window_status_current -readonly show_window_in_window_status_current="#[fg=$thm_bg,bg=$thm_blue,nobold,noitalics,nounderscore]$l_left_separator #[fg=$thm_bg,bg=$thm_blue,nobold,noitalics,nounderscore]#W  #I #[fg=$thm_blue,bg=$thm_bg,nobold,noitalics,nounderscore]$l_right_separator" - -local show_user -readonly show_user="#[fg=$thm_cyan,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_cyan,nobold,nounderscore,noitalics] $user_icon #(whoami) $r_right_separator" - -local show_host -readonly show_host="#[fg=$thm_magenta,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_magenta,nobold,nounderscore,noitalics] $host_icon #H $r_right_separator" - -local show_date_time -readonly show_date_time="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics] $datetime_icon $date_time $r_right_separator" - diff --git a/src/powerline-status-line.conf b/src/powerline-status-line.conf deleted file mode 100644 index 217c1c6..0000000 --- a/src/powerline-status-line.conf +++ /dev/null @@ -1,29 +0,0 @@ -local show_directory -readonly show_directory="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #{b:pane_current_path} $r_right_separator" - -local show_window -readonly show_window="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics] #W $r_right_separator" - -local show_session -readonly show_session="#[fg=$thm_green,bg=$thm_bg,nobold,nounderscore,noitalics]#{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}$r_left_separator#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg] #S #{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg]$r_right_separator" - -local show_directory_in_window_status -readonly show_directory_in_window_status="#[fg=$thm_bg,bg=$thm_gray,nobold,noitalics,nounderscore]$l_left_separator #[fg=$thm_fg,bg=$thm_gray,nobold,noitalics,nounderscore]#I  #{b:pane_current_path} #[fg=$thm_gray,bg=$thm_bg,nobold,noitalics,nounderscore]$l_right_separator" - -local show_directory_in_window_status_current -readonly show_directory_in_window_status_current="#[fg=$thm_bg,bg=$thm_blue,nobold,noitalics,nounderscore]$l_left_separator #[fg=$thm_bg,bg=$thm_blue,nobold,noitalics,nounderscore]#I  #{b:pane_current_path} #[fg=$thm_blue,bg=$thm_bg,nobold,noitalics,nounderscore]$l_right_separator" - -local show_window_in_window_status -readonly show_window_in_window_status="#[fg=$thm_bg,bg=$thm_gray,nobold,noitalics,nounderscore]$l_left_separator #[fg=$thm_fg,bg=$thm_gray,nobold,noitalics,nounderscore]#W  #I #[fg=$thm_gray,bg=$thm_bg,nobold,noitalics,nounderscore]$l_right_separator" - -local show_window_in_window_status_current -readonly show_window_in_window_status_current="#[fg=$thm_bg,bg=$thm_blue,nobold,noitalics,nounderscore]$l_left_separator #[fg=$thm_bg,bg=$thm_blue,nobold,noitalics,nounderscore]#W  #I #[fg=$thm_blue,bg=$thm_bg,nobold,noitalics,nounderscore]$l_right_separator" - -local show_user -readonly show_user="#[fg=$thm_cyan,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_cyan,nobold,nounderscore,noitalics] #(whoami) $r_right_separator" - -local show_host -readonly show_host="#[fg=$thm_magenta,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_magenta,nobold,nounderscore,noitalics] #H $r_right_separator" - -local show_date_time -readonly show_date_time="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$r_left_separator#[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics] $date_time $r_right_separator" diff --git a/status/application.sh b/status/application.sh index 6ccf44a..5427479 100644 --- a/status/application.sh +++ b/status/application.sh @@ -1,16 +1,10 @@ show_application() { + local index=$1 local icon="$(get_tmux_option "@catppuccin_application_icon" "")" + local color="$(get_tmux_option "@catppuccin_application_color" "$thm_pink")" + local text="$(get_tmux_option "@catppuccin_application_text" "#W")" - if [[ $1 -eq 0 || $status_connect_separator == "no" ]] - then - local show_left_separator="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" - else - local show_left_separator="#[fg=$thm_pink,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" - fi + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) - local show_icon="#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics]$icon " - local show_text="#[fg=$thm_fg,bg=$thm_gray] #W" - local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" - - echo "$show_left_separator$show_icon$show_text$show_right_separator" + echo $module } diff --git a/status/date_time.sh b/status/date_time.sh index 76000a4..e95f37a 100644 --- a/status/date_time.sh +++ b/status/date_time.sh @@ -1,18 +1,11 @@ show_date_time() { - local icon="$(get_tmux_option "@catppuccin_datetime_icon" "󰃰")" - local format="$(get_tmux_option "@catppuccin_date_time_format" "%Y-%m-%d %H:%M")" + local index=$1 + local icon="$(get_tmux_option "@catppuccin_date_time_icon" "󰃰")" + local color="$(get_tmux_option "@catppuccin_date_time_color" "$thm_blue")" + local text="$(get_tmux_option "@catppuccin_date_time_text" "%Y-%m-%d %H:%M:%S")" - if [[ $1 -eq 0 || $status_connect_separator == "no" ]] - then - local show_left_separator="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" - else - local show_left_separator="#[fg=$thm_blue,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" - fi + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) - local show_icon="#[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics]$icon " - local show_text="#[fg=$thm_fg,bg=$thm_gray] $format" - local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" - - echo "$show_left_separator$show_icon$show_text$show_right_separator" + echo $module } diff --git a/status/directory.sh b/status/directory.sh index 16c2f5c..5d382f8 100644 --- a/status/directory.sh +++ b/status/directory.sh @@ -1,16 +1,10 @@ show_directory() { + local index=$1 local icon="$(get_tmux_option "@catppuccin_directory_icon" "")" + local color="$(get_tmux_option "@catppuccin_directory_color" "$thm_pink")" + local text="$(get_tmux_option "@catppuccin_directory_text" "#{b:pane_current_path}")" - if [[ $1 -eq 0 || $status_connect_separator == "no" ]] - then - local show_left_separator="#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" - else - local show_left_separator="#[fg=$thm_pink,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" - fi + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) - local show_icon="#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics]$icon " - local show_text="#[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path}" - local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" - - echo "$show_left_separator$show_icon$show_text$show_right_separator" + echo $module } diff --git a/status/host.sh b/status/host.sh index 970d369..25b77a8 100644 --- a/status/host.sh +++ b/status/host.sh @@ -1,16 +1,10 @@ show_host() { + local index=$1 local icon="$(get_tmux_option "@catppuccin_host_icon" "󰒋")" + local color="$(get_tmux_option "@catppuccin_host_color" "$thm_blue")" + local text="$(get_tmux_option "@catppuccin_host_text" "#H")" - if [[ $1 -eq 0 || $status_connect_separator == "no" ]] - then - local show_left_separator="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" - else - local show_left_separator="#[fg=$thm_blue,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" - fi + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) - local show_icon="#[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics]$icon " - local show_text="#[fg=$thm_fg,bg=$thm_gray] #H" - local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" - - echo "$show_left_separator$show_icon$show_text$show_right_separator" + echo $module } diff --git a/status/session.sh b/status/session.sh index cea9d12..2ff3bc1 100644 --- a/status/session.sh +++ b/status/session.sh @@ -1,7 +1,9 @@ show_session() { + local index=$1 local icon="$(get_tmux_option "@catppuccin_session_icon" "")" + local text="$(get_tmux_option "@catppuccin_host_text" "#S")" - if [[ $1 -eq 0 || $status_connect_separator == "no" ]] + if [[ $index -eq 0 || $status_connect_separator == "no" ]] then local show_left_separator="#[fg=$thm_green]#[bg=$thm_bg]#{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}$status_left_separator" else @@ -9,8 +11,18 @@ show_session() { fi local show_icon="#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg]$icon " - local show_text="#[fg=$thm_fg,bg=$thm_gray] #S" - local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" + + if [[ $status_color_fill == "icon" ]] + then + local show_text="#[fg=$thm_fg,bg=$thm_gray] $text" + local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" + fi + + if [[ $status_color_fill == "all" ]] + then + local show_text="#[fg=$thm_bg]$text" + local show_right_separator="#[fg=$thm_green]#[bg=$thm_bg]#{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}$status_right_separator" + fi echo "$show_left_separator$show_icon$show_text$show_right_separator" } diff --git a/status/user.sh b/status/user.sh index da494eb..694d0ae 100644 --- a/status/user.sh +++ b/status/user.sh @@ -1,16 +1,10 @@ show_user() { + local index=$1 local icon="$(get_tmux_option "@catppuccin_user_icon" "")" + local color="$(get_tmux_option "@catppuccin_user_color" "$thm_blue")" + local text="$(get_tmux_option "@catppuccin_user_text" "#(whoami)")" - if [[ $1 -eq 0 || $status_connect_separator == "no" ]] - then - local show_left_separator="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator" - else - local show_left_separator="#[fg=$thm_blue,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator" - fi + local module=$( build_status_module "$index" "$icon" "$color" "$text" ) - local show_icon="#[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics]$icon " - local show_text="#[fg=$thm_fg,bg=$thm_gray] #(whoami)" - local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator" - - echo "$show_left_separator$show_icon$show_text$show_right_separator" + echo $module } diff --git a/window/application_in_window.sh b/window/application_in_window.sh deleted file mode 100644 index 0de86e7..0000000 --- a/window/application_in_window.sh +++ /dev/null @@ -1,37 +0,0 @@ -show_application_in_window() { - if [[ $window_color_fill == "number" ]] - then - local show_icon="#[fg=$thm_bg,bg=$thm_blue]#I" - local show_middle_separator="#[fg=$thm_blue,bg=$thm_gray,nobold,nounderscore,noitalics]$window_middle_separator" - local show_text="#[fg=$thm_fg,bg=$thm_gray]#W" - - if [[ $window_icon_position == "right" ]] - then - local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_right_separator="#[fg=$thm_blue,bg=$thm_bg]$window_right_separator" - - echo "$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" - else - local show_left_separator="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$window_right_separator" - - echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" - fi - - else - local show_left_separator="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_icon="#[fg=$thm_bg,bg=$thm_blue]#I" - local show_middle_separator="#[fg=$thm_gray,bg=$thm_blue,nobold,nounderscore,noitalics]$window_middle_separator" - local show_text="#[fg=$thm_bg,bg=$thm_blue]#{b:pane_current_path}" - local show_right_separator="#[fg=$thm_blue,bg=$thm_bg]$window_right_separator" - - if [[ $window_icon_position == "right" ]] - then - echo "$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" - - else - echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" - fi - - fi -} diff --git a/window/application_in_window_current.sh b/window/application_in_window_current.sh deleted file mode 100644 index 51f8d3e..0000000 --- a/window/application_in_window_current.sh +++ /dev/null @@ -1,40 +0,0 @@ -show_application_in_window_current() { - if [[ $window_color_fill == "number" ]] - then - local show_icon="#[fg=$thm_bg,bg=$thm_orange]#I" - local show_middle_separator="#[fg=$thm_orange,bg=$thm_bg,nobold,nounderscore,noitalics]$window_middle_separator" - local show_text="#[fg=$thm_fg,bg=$thm_bg]#W" - - if [[ $window_icon_position == "right" ]] - then - local show_left_separator="#[fg=$thm_bg,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_right_separator="#[fg=$thm_orange,bg=$thm_bg]$window_right_separator" - - echo "$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" - - else - local show_left_separator="#[fg=$thm_orange,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_right_separator="#[fg=$thm_bg,bg=$thm_bg]$window_right_separator" - - echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" - - fi - - else - local show_left_separator="#[fg=$thm_orange,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_icon="#[fg=$thm_bg,bg=$thm_orange]#I" - local show_middle_separator="#[fg=$thm_bg,bg=$thm_orange,nobold,nounderscore,noitalics]$window_middle_separator" - local show_text="#[fg=$thm_bg,bg=$thm_orange]#{b:pane_current_path}" - local show_right_separator="#[fg=$thm_orange,bg=$thm_bg]$window_right_separator" - - if [[ $window_icon_position == "right" ]] - then - echo "$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" - - else - echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" - - fi - - fi -} diff --git a/window/directory_in_window.sh b/window/directory_in_window.sh deleted file mode 100644 index 457b340..0000000 --- a/window/directory_in_window.sh +++ /dev/null @@ -1,38 +0,0 @@ -show_directory_in_window() { - if [[ $window_color_fill == "number" ]] - then - local show_icon="#[fg=$thm_bg,bg=$thm_blue]#I" - local show_middle_separator="#[fg=$thm_blue,bg=$thm_gray,nobold,nounderscore,noitalics]$window_middle_separator" - local show_text="#[fg=$thm_fg,bg=$thm_gray]#{b:pane_current_path}" - - if [[ $window_icon_position == "right" ]] - then - local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_right_separator="#[fg=$thm_blue,bg=$thm_bg]$window_right_separator" - - echo "$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" - else - local show_left_separator="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$window_right_separator" - - echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" - fi - - else - local show_left_separator="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_icon="#[fg=$thm_bg,bg=$thm_blue]#I" - local show_middle_separator="#[fg=$thm_gray,bg=$thm_blue,nobold,nounderscore,noitalics]$window_middle_separator" - local show_text="#[fg=$thm_bg,bg=$thm_blue]#{b:pane_current_path}" - local show_right_separator="#[fg=$thm_blue,bg=$thm_bg]$window_right_separator" - - if [[ $window_icon_position == "right" ]] - then - echo "$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" - - else - echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" - fi - - fi - -} diff --git a/window/directory_in_window_current.sh b/window/directory_in_window_current.sh deleted file mode 100644 index e4c12d5..0000000 --- a/window/directory_in_window_current.sh +++ /dev/null @@ -1,41 +0,0 @@ -show_directory_in_window_current() { - if [[ $window_color_fill == "number" ]] - then - local show_icon="#[fg=$thm_bg,bg=$thm_orange]#I" - local show_middle_separator="#[fg=$thm_orange,bg=$thm_bg,nobold,nounderscore,noitalics]$window_middle_separator" - local show_text="#[fg=$thm_fg,bg=$thm_bg]#{b:pane_current_path}" - - if [[ $window_icon_position == "right" ]] - then - local show_left_separator="#[fg=$thm_bg,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_right_separator="#[fg=$thm_orange,bg=$thm_bg]$window_right_separator" - - echo "$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" - - else - local show_left_separator="#[fg=$thm_orange,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_right_separator="#[fg=$thm_bg,bg=$thm_bg]$window_right_separator" - - echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" - - fi - - else - local show_left_separator="#[fg=$thm_orange,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" - local show_icon="#[fg=$thm_bg,bg=$thm_orange]#I" - local show_middle_separator="#[fg=$thm_bg,bg=$thm_orange,nobold,nounderscore,noitalics]$window_middle_separator" - local show_text="#[fg=$thm_bg,bg=$thm_orange]#{b:pane_current_path}" - local show_right_separator="#[fg=$thm_orange,bg=$thm_bg]$window_right_separator" - - if [[ $window_icon_position == "right" ]] - then - echo "$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" - - else - echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" - - fi - - fi - -} diff --git a/window/window_current_format.sh b/window/window_current_format.sh new file mode 100644 index 0000000..606680d --- /dev/null +++ b/window/window_current_format.sh @@ -0,0 +1,60 @@ +show_window_current_format() { + local icon="#I" + local color="$thm_orange" + local background="$thm_bg" + local text + + local window_format + + if [[ $window_format_style == "directory" ]] + then + text="$(get_tmux_option "@catppuccin_window_current_format_directory_text" "#{b:pane_current_path}")" + fi + + if [[ $window_format_style == "application" ]] + then + text="#W" + fi + + if [[ $window_color_fill == "all" ]] + then + local show_left_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$window_left_separator" + local show_icon="#[fg=$background,bg=$color]$icon" + local show_middle_separator="#[fg=$background,bg=$color,nobold,nounderscore,noitalics]$window_middle_separator" + local show_text="#[fg=$background,bg=$color]$text" + local show_right_separator="#[fg=$color,bg=$background]$window_right_separator" + + fi + + if [[ $window_color_fill == "number" ]] + then + local show_icon="#[fg=$background,bg=$color]$icon" + local show_middle_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$window_middle_separator" + local show_text="#[fg=$thm_fg,bg=$background]$text" + + if [[ $window_icon_position == "right" ]] + then + local show_left_separator="#[fg=$background,bg=$background,nobold,nounderscore,noitalics]$window_left_separator" + local show_right_separator="#[fg=$color,bg=$background]$window_right_separator" + fi + + if [[ $window_icon_position == "left" ]] + then + local show_right_separator="#[fg=$background,bg=$background,nobold,nounderscore,noitalics]$window_right_separator" + local show_left_separator="#[fg=$color,bg=$background]$window_left_separator" + fi + + fi + + if [[ $window_icon_position == "right" ]] + then + window_format="$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" + fi + + if [[ $window_icon_position == "left" ]] + then + window_format="$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" + fi + + echo $window_format +} diff --git a/window/window_format.sh b/window/window_format.sh new file mode 100644 index 0000000..73cfc7b --- /dev/null +++ b/window/window_format.sh @@ -0,0 +1,59 @@ +show_window_format() { + local icon="#I" + local color="$thm_blue" + local text + + local window_format + + if [[ $window_format_style == "directory" ]] + then + text="$(get_tmux_option "@catppuccin_window_format_directory_text" "#{b:pane_current_path}")" + fi + + if [[ $window_format_style == "application" ]] + then + text="#W" + fi + + if [[ $window_color_fill == "all" ]] + then + local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" + local show_icon="#[fg=$thm_fg,bg=$thm_gray]$icon" + local show_middle_separator="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics]$window_middle_separator" + local show_text="#[fg=$thm_fg,bg=$thm_gray]$text" + local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$window_right_separator" + + fi + + if [[ $window_color_fill == "number" ]] + then + local show_icon="#[fg=$thm_bg,bg=$color]$icon" + local show_middle_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$window_middle_separator" + local show_text="#[fg=$thm_fg,bg=$thm_gray]$text" + + if [[ $window_icon_position == "right" ]] + then + local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator" + local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator" + fi + + if [[ $window_icon_position == "left" ]] + then + local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_right_separator" + local show_left_separator="#[fg=$color,bg=$thm_bg]$window_left_separator" + fi + + fi + + if [[ $window_icon_position == "right" ]] + then + window_format="$show_left_separator$show_text$show_middle_separator$show_icon$show_right_separator" + fi + + if [[ $window_icon_position == "left" ]] + then + window_format="$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator" + fi + + echo $window_format +}