Skip to content

Commit

Permalink
Move code out of main (#172)
Browse files Browse the repository at this point in the history
* feat(status, window): add option to make overwrite status background color, add option to set the separator between windows

* feat(window): update documentation

* feat(window): update documentation

* feat(refactor): move code out of main and into separated files

* Update catppuccin.tmux

Co-authored-by: vdbe <[email protected]>

* Update catppuccin.tmux

Co-authored-by: vdbe <[email protected]>

---------

Co-authored-by: vdbe <[email protected]>
  • Loading branch information
89iuv and vdbe authored Mar 24, 2024
1 parent 809361f commit e2d3456
Show file tree
Hide file tree
Showing 6 changed files with 313 additions and 297 deletions.
68 changes: 68 additions & 0 deletions builder/module_builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/sh

build_status_module() {
local index=$1
local icon=$2
local color=$3
local text=$4

if [ "$status_fill" = "icon" ]
then
local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator"

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"

if [ "$status_connect_separator" = "yes" ]
then
local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=$thm_gray,nobold,nounderscore,noitalics]$status_right_separator"

else
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator"
fi

fi

if [ "$status_fill" = "all" ]
then
local show_left_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_left_separator"

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_gray,nobold,nounderscore,noitalics]$status_right_separator"

if [ "$status_connect_separator" = "yes" ]
then
local show_left_separator="#[fg=$color,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$color,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"

else
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator"
fi

fi

if [ "$status_right_separator_inverse" = "yes" ]
then
if [ "$status_connect_separator" = "yes" ]
then
local show_right_separator="#[fg=$thm_gray,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"
else
local show_right_separator="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$status_right_separator"
fi
fi

if [ $(($index)) -eq 0 ]
then
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator"
fi

echo "$show_left_separator$show_icon$show_text$show_right_separator"
}

64 changes: 64 additions & 0 deletions builder/pane_builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh

build_pane_format() {
local number=$1
local color=$2
local background=$3
local text=$4
local fill=$5

if [ "$pane_status_enable" = "yes" ]
then
if [ "$fill" = "none" ]
then
local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$pane_left_separator"
local show_number="#[fg=$thm_fg,bg=$thm_gray]$number"
local show_middle_separator="#[fg=$thm_fg,bg=$thm_gray,nobold,nounderscore,noitalics]$pane_middle_separator"
local show_text="#[fg=$thm_fg,bg=$thm_gray]$text"
local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$pane_right_separator"
fi

if [ "$fill" = "all" ]
then
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$pane_left_separator"
local show_number="#[fg=$background,bg=$color]$number"
local show_middle_separator="#[fg=$background,bg=$color,nobold,nounderscore,noitalics]$pane_middle_separator"
local show_text="#[fg=$background,bg=$color]$text"
local show_right_separator="#[fg=$color,bg=$thm_bg]$pane_right_separator"
fi

if [ "$fill" = "number" ]
then
local show_number="#[fg=$background,bg=$color]$number"
local show_middle_separator="#[fg=$color,bg=$background,nobold,nounderscore,noitalics]$pane_middle_separator"
local show_text="#[fg=$thm_fg,bg=$background]$text"

if [ "$pane_number_position" = "right" ]
then
local show_left_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$pane_left_separator"
local show_right_separator="#[fg=$color,bg=$thm_bg]$pane_right_separator"
fi

if [ "$pane_number_position" = "left" ]
then
local show_right_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$pane_right_separator"
local show_left_separator="#[fg=$color,bg=$thm_bg]$pane_left_separator"
fi

fi

local final_pane_format

if [ "$pane_number_position" = "right" ]
then
final_pane_format="$show_left_separator$show_text$show_middle_separator$show_number$show_right_separator"
fi

if [ "$pane_number_position" = "left" ]
then
final_pane_format="$show_left_separator$show_number$show_middle_separator$show_text$show_right_separator"
fi

echo "$final_pane_format"
fi
}
101 changes: 101 additions & 0 deletions builder/window_builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/bin/sh

build_window_format() {
local number=$1
local color=$2
local background=$3
local text=$4
local fill=$5

if [ "$window_status_enable" = "yes" ]
then
local icon="$( build_window_icon )"
text="$text$icon"
fi

if [ "$fill" = "none" ]
then
local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_number="#[fg=$thm_fg,bg=$thm_gray]$number"
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 [ "$fill" = "all" ]
then
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_number="#[fg=$background,bg=$color]$number"
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=$thm_bg]$window_right_separator"

fi

if [ "$fill" = "number" ]
then
local show_number="#[fg=$background,bg=$color]$number"
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_number_position" = "right" ]
then
local show_left_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator"
fi

if [ "$window_number_position" = "left" ]
then
local show_right_separator="#[fg=$background,bg=$thm_bg,nobold,nounderscore,noitalics]$window_right_separator"
local show_left_separator="#[fg=$color,bg=$thm_bg]$window_left_separator"
fi

fi

local final_window_format

if [ "$window_number_position" = "right" ]
then
final_window_format="$show_left_separator$show_text$show_middle_separator$show_number$show_right_separator"
fi

if [ "$window_number_position" = "left" ]
then
final_window_format="$show_left_separator$show_number$show_middle_separator$show_text$show_right_separator"
fi

echo "$final_window_format"
}

build_window_icon() {
local window_status_icon_enable=$(get_tmux_option "@catppuccin_window_status_icon_enable" "yes")
local custom_icon_window_last=$(get_tmux_option "@catppuccin_icon_window_last" "󰖰")
local custom_icon_window_current=$(get_tmux_option "@catppuccin_icon_window_current" "󰖯")
local custom_icon_window_zoom=$(get_tmux_option "@catppuccin_icon_window_zoom" "󰁌")
local custom_icon_window_mark=$(get_tmux_option "@catppuccin_icon_window_mark" "󰃀")
local custom_icon_window_silent=$(get_tmux_option "@catppuccin_icon_window_silent" "󰂛")
local custom_icon_window_activity=$(get_tmux_option "@catppuccin_icon_window_activity" "󱅫")
local custom_icon_window_bell=$(get_tmux_option "@catppuccin_icon_window_bell" "󰂞")

if [ "$window_status_icon_enable" = "yes" ]
then
# #!~[*-]MZ
local show_window_status=""
show_window_status+="#{?window_activity_flag, ${custom_icon_window_activity},}"
show_window_status+="#{?window_bell_flag, ${custom_icon_window_bell},}"
show_window_status+="#{?window_silence_flag, ${custom_icon_window_silent},}"
show_window_status+="#{?window_active, ${custom_icon_window_current},}"
show_window_status+="#{?window_last_flag, ${custom_icon_window_last},}"
show_window_status+="#{?window_marked_flag, ${custom_icon_window_mark},}"
show_window_status+="#{?window_zoomed_flag, ${custom_icon_window_zoom},}"

fi

if [ "$window_status_icon_enable" = "no" ]
then
local show_window_status=" #F"
fi

echo "$show_window_status"
}
Loading

0 comments on commit e2d3456

Please sign in to comment.