Move code out of main (#172)
* 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 <44153531+vdbe@users.noreply.github.com> * Update catppuccin.tmux Co-authored-by: vdbe <44153531+vdbe@users.noreply.github.com> --------- Co-authored-by: vdbe <44153531+vdbe@users.noreply.github.com>
This commit is contained in:
parent
809361f5c2
commit
e2d345648c
6 changed files with 313 additions and 297 deletions
68
builder/module_builder.sh
Normal file
68
builder/module_builder.sh
Normal file
|
@ -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
builder/pane_builder.sh
Normal file
64
builder/pane_builder.sh
Normal file
|
@ -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
builder/window_builder.sh
Normal file
101
builder/window_builder.sh
Normal file
|
@ -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"
|
||||||
|
}
|
305
catppuccin.tmux
305
catppuccin.tmux
|
@ -1,304 +1,15 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Set path of script
|
||||||
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
get_tmux_option() {
|
# import
|
||||||
local option value default
|
source "${PLUGIN_DIR}/builder/module_builder.sh"
|
||||||
option="$1"
|
source "${PLUGIN_DIR}/builder/window_builder.sh"
|
||||||
default="$2"
|
source "${PLUGIN_DIR}/builder/pane_builder.sh"
|
||||||
value=$(tmux show-option -gqv "$option")
|
source "${PLUGIN_DIR}/utils/tmux_utils.sh"
|
||||||
|
source "${PLUGIN_DIR}/utils/module_utils.sh"
|
||||||
|
|
||||||
if [ -n "$value" ]
|
|
||||||
then
|
|
||||||
if [ "$value" = "null" ]
|
|
||||||
then
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "$value"
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "$default"
|
|
||||||
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set() {
|
|
||||||
local option=$1
|
|
||||||
local value=$2
|
|
||||||
tmux_commands+=(set-option -gq "$option" "$value" ";")
|
|
||||||
}
|
|
||||||
|
|
||||||
setw() {
|
|
||||||
local option=$1
|
|
||||||
local value=$2
|
|
||||||
tmux_commands+=(set-window-option -gq "$option" "$value" ";")
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
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_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"
|
|
||||||
}
|
|
||||||
|
|
||||||
load_modules() {
|
|
||||||
local modules_list=$1
|
|
||||||
shift
|
|
||||||
local module_directories=("$@")
|
|
||||||
|
|
||||||
local -i module_index=0;
|
|
||||||
local module_name
|
|
||||||
local module_path
|
|
||||||
local loaded_modules
|
|
||||||
local IN=$modules_list
|
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash#15988793
|
|
||||||
while [ "$IN" != "$iter" ] ;do
|
|
||||||
# extract the substring from start of string up to delimiter.
|
|
||||||
iter=${IN%% *}
|
|
||||||
# delete this first "element" AND next separator, from $IN.
|
|
||||||
IN="${IN#$iter }"
|
|
||||||
# Print (or doing anything with) the first "element".
|
|
||||||
|
|
||||||
module_name=$iter
|
|
||||||
|
|
||||||
for module_dir in "${module_directories[@]}" ; do
|
|
||||||
module_path="$module_dir/$module_name.sh"
|
|
||||||
|
|
||||||
if [ -r "$module_path" ]; then
|
|
||||||
source "$module_path"
|
|
||||||
loaded_modules="$loaded_modules$( "show_$module_name" "$module_index" )"
|
|
||||||
module_index+=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "$loaded_modules"
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
# Aggregate all commands in one array
|
# Aggregate all commands in one array
|
||||||
|
|
37
utils/module_utils.sh
Normal file
37
utils/module_utils.sh
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
load_modules() {
|
||||||
|
local modules_list=$1
|
||||||
|
shift
|
||||||
|
local module_directories=("$@")
|
||||||
|
|
||||||
|
local -i module_index=0;
|
||||||
|
local module_name
|
||||||
|
local module_path
|
||||||
|
local loaded_modules
|
||||||
|
local IN=$modules_list
|
||||||
|
|
||||||
|
# https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash#15988793
|
||||||
|
while [ "$IN" != "$iter" ] ;do
|
||||||
|
# extract the substring from start of string up to delimiter.
|
||||||
|
iter=${IN%% *}
|
||||||
|
# delete this first "element" AND next separator, from $IN.
|
||||||
|
IN="${IN#$iter }"
|
||||||
|
# Print (or doing anything with) the first "element".
|
||||||
|
|
||||||
|
module_name=$iter
|
||||||
|
|
||||||
|
for module_dir in "${module_directories[@]}" ; do
|
||||||
|
module_path="$module_dir/$module_name.sh"
|
||||||
|
|
||||||
|
if [ -r "$module_path" ]; then
|
||||||
|
source "$module_path"
|
||||||
|
loaded_modules="$loaded_modules$( "show_$module_name" "$module_index" )"
|
||||||
|
module_index+=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "$loaded_modules"
|
||||||
|
}
|
35
utils/tmux_utils.sh
Normal file
35
utils/tmux_utils.sh
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
get_tmux_option() {
|
||||||
|
local option value default
|
||||||
|
option="$1"
|
||||||
|
default="$2"
|
||||||
|
value=$(tmux show-option -gqv "$option")
|
||||||
|
|
||||||
|
if [ -n "$value" ]
|
||||||
|
then
|
||||||
|
if [ "$value" = "null" ]
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "$value"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "$default"
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
set() {
|
||||||
|
local option=$1
|
||||||
|
local value=$2
|
||||||
|
tmux_commands+=(set-option -gq "$option" "$value" ";")
|
||||||
|
}
|
||||||
|
|
||||||
|
setw() {
|
||||||
|
local option=$1
|
||||||
|
local value=$2
|
||||||
|
tmux_commands+=(set-window-option -gq "$option" "$value" ";")
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue