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

View file

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

View file

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

View file

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

View file

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

59
window/window_format.sh Normal file
View file

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