feat(modules): refactor modules and extract common functionality

This commit is contained in:
Valentin Uveges 2023-08-08 11:45:45 +03:00
parent 56a447094a
commit 3b4bf404db
18 changed files with 200 additions and 352 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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"
}

View file

@ -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
}