feat(modules): extract date_time module
This commit is contained in:
parent
e7b50832f9
commit
a436f766cb
3 changed files with 79 additions and 1 deletions
|
@ -31,6 +31,31 @@ setw() {
|
||||||
tmux_commands+=(set-window-option -gq "$option" "$value" ";")
|
tmux_commands+=(set-window-option -gq "$option" "$value" ";")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load_modules() {
|
||||||
|
local loaded_modules
|
||||||
|
|
||||||
|
local modules_path=$1
|
||||||
|
local modules_list=$2
|
||||||
|
|
||||||
|
local modules_array
|
||||||
|
read -a modules_array <<< "$modules_list"
|
||||||
|
|
||||||
|
local module_name
|
||||||
|
for module_name in ${modules_array[@]}
|
||||||
|
do
|
||||||
|
local module_path=$modules_path/$module_name.sh
|
||||||
|
source $module_path
|
||||||
|
|
||||||
|
if [[ 0 -eq $? ]]
|
||||||
|
then
|
||||||
|
loaded_modules=$loaded_modules$( show_$module_name )
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $loaded_modules
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local theme
|
local theme
|
||||||
theme="$(get_tmux_option "@catppuccin_flavour" "mocha")"
|
theme="$(get_tmux_option "@catppuccin_flavour" "mocha")"
|
||||||
|
@ -196,7 +221,16 @@ main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set status-left ""
|
set status-left ""
|
||||||
set status-right "${right_column1}${right_column2}"
|
|
||||||
|
|
||||||
|
local status_left_separator=$r_left_separator
|
||||||
|
local status_right_separator=$l_right_separator
|
||||||
|
|
||||||
|
local status_modules="$(get_tmux_option "@catppuccin_status_modules" "")"
|
||||||
|
|
||||||
|
local loaded_modules=$( load_modules "$PLUGIN_DIR/modules" "$status_modules")
|
||||||
|
set status-right "${right_column1}${right_column2}${loaded_modules}"
|
||||||
|
|
||||||
|
|
||||||
setw window-status-format "${window_status_format}"
|
setw window-status-format "${window_status_format}"
|
||||||
setw window-status-current-format "${window_status_current_format}"
|
setw window-status-current-format "${window_status_current_format}"
|
||||||
|
|
14
modules/date_time.sh
Normal file
14
modules/date_time.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
show_date_time() {
|
||||||
|
local date_time_icon="$(get_tmux_option "@catppuccin_datetime_icon" "")"
|
||||||
|
local date_time_format="$(get_tmux_option "@catppuccin_date_time_format" "%Y-%m-%d %H:%M")"
|
||||||
|
|
||||||
|
local show_left_separator="#[fg=$thm_blue,bg=$thm_bg,nobold,nounderscore,noitalics]$status_left_separator"
|
||||||
|
local show_date_time_icon="#[fg=$thm_bg,bg=$thm_blue,nobold,nounderscore,noitalics]$datetime_icon"
|
||||||
|
local show_date_time_text="#[fg=$thm_fg,bg=$thm_gray]$date_time_format"
|
||||||
|
local show_right_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$status_right_separator"
|
||||||
|
|
||||||
|
local show_date_time=$show_left_separator$show_date_time_icon" "$show_date_time_text$show_right_separator
|
||||||
|
|
||||||
|
echo $show_date_time
|
||||||
|
}
|
||||||
|
|
30
test_cat.sh
Executable file
30
test_cat.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
load_modules() {
|
||||||
|
local loaded_modules
|
||||||
|
|
||||||
|
local modules_path=$1
|
||||||
|
local modules_list=$2
|
||||||
|
|
||||||
|
local modules_array
|
||||||
|
read -a modules_array <<< "$modules_list"
|
||||||
|
|
||||||
|
local module_name
|
||||||
|
for module_name in ${modules_array[@]}
|
||||||
|
do
|
||||||
|
local module_path=$modules_path/$module_name.sh
|
||||||
|
source $module_path
|
||||||
|
|
||||||
|
if [[ 0 -eq $? ]]
|
||||||
|
then
|
||||||
|
loaded_modules=$loaded_modules$( show_$module_name )
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $loaded_modules
|
||||||
|
}
|
||||||
|
|
||||||
|
module_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/modules
|
||||||
|
module_list="user host date_time"
|
||||||
|
echo $( load_modules "$module_path" "$module_list" )
|
Loading…
Add table
Add a link
Reference in a new issue