New TMUX statusbar and config cleanup

This commit is contained in:
2024-09-27 20:03:50 +01:00
parent 79c23ef374
commit cad1e93d95
73 changed files with 3266 additions and 93 deletions

View File

@@ -0,0 +1,6 @@
shell=bash
# TODO: Find a way to declare color variables
disable=SC2154
external-sources=true

View File

@@ -0,0 +1,2 @@
# Theme plugin
Forked from the TMUX Catppuccin theme and adapted for Adwaita.

View File

@@ -0,0 +1,49 @@
#!/bin/sh
build_status_module() {
local index="$1"
local icon="$2"
local color="$3"
local text="$4"
if [ "$status_fill" = "icon" ]; then
local bg
local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon "
local show_text="#[fg=$thm_fg,bg=$thm_gray] $text"
if [ "$status_connect_separator" = "yes" ]; then
bg="$thm_gray"
else
bg="default"
fi
local show_left_separator="#[fg=$color,bg=$bg,nobold,nounderscore,noitalics]$status_left_separator"
local show_middle_separator="#[fg=$color,bg=$thm_gray,nobold,nounderscore,noitalics]$status_middle_separator"
local show_right_separator="#[fg=$thm_gray,bg=$bg,nobold,nounderscore,noitalics]$status_right_separator"
fi
if [ "$status_fill" = "all" ]; then
local show_icon="#[fg=$thm_bg,bg=$color,nobold,nounderscore,noitalics]$icon "
local show_text="#[fg=$thm_bg,bg=$color]$text"
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=default,nobold,nounderscore,noitalics]$status_left_separator"
local show_right_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$status_right_separator"
fi
fi
if [ $((index)) -eq 0 ]; then
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$status_left_separator"
fi
if [ -z "$icon" ] ; then
show_icon=""
fi
echo "$show_left_separator$show_icon$show_middle_separator$show_text$show_right_separator"
}

View 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=default,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=default]$pane_right_separator"
fi
if [ "$fill" = "all" ]
then
local show_left_separator="#[fg=$color,bg=default,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=default]$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=default,nobold,nounderscore,noitalics]$pane_left_separator"
local show_right_separator="#[fg=$color,bg=default]$pane_right_separator"
fi
if [ "$pane_number_position" = "left" ]
then
local show_right_separator="#[fg=$background,bg=default,nobold,nounderscore,noitalics]$pane_right_separator"
local show_left_separator="#[fg=$color,bg=default]$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
}

View File

@@ -0,0 +1,188 @@
#!/bin/sh
show_window_status=
build_window_format() {
local number="$1"
local color="$2"
local background="$3"
local text="$4"
local fill="$5"
local window_type="$6"
# NOTE: For backwards compatibility remove before 1.0.0 and update default for
# `@catppuccin_window_status`
if [ "$window_status" = "no" ]; then
window_status_enable="$(get_tmux_option "@catppuccin_window_status_enable" "")"
if [ -n "$window_status_enable" ]; then
tmux_echo "catppuccin warning: \\\"@catppuccin_window_status_enable\\\" and \\\"@catppuccin_window_status_icon_enable\\\" has been replaced by\n\t \
\\\"@catppuccin_window_status\\\" with the options \\\"no\\\", \\\"icon\\\" and \\\"text\\\"" 104
if [ "$window_status_enable" = "yes" ]; then
window_status_icon_enable="$(get_tmux_option "@catppuccin_window_status_icon_enable" "yes")"
if [ "$window_status_icon_enable" = "yes" ]; then
window_status="icon"
else
window_status="text"
fi
else
window_status="no"
fi
fi
fi
if [ ! "$window_status" = "no" ]; then
local icon
icon="$(build_window_icon)"
text="$text$icon"
fi
if [ "$window_type" = "current" ]; then
add_tmux_batch_option "@catppuccin_window_current_left_separator"
add_tmux_batch_option "@catppuccin_window_current_middle_separator"
add_tmux_batch_option "@catppuccin_window_current_right_separator"
run_tmux_batch_commands
window_left_separator=$(get_tmux_batch_option "@catppuccin_window_current_left_separator" "$window_left_separator")
window_middle_separator=$(get_tmux_batch_option "@catppuccin_window_current_middle_separator" "$window_middle_separator")
window_right_separator=$(get_tmux_batch_option "@catppuccin_window_current_right_separator" "$window_right_separator")
fi
if [ "$fill" = "none" ]; then
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"
if [ "$status_connect_separator" = "yes" ]; then
local show_left_separator="#[fg=$thm_gray,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=$thm_bg]$window_right_separator"
else
local show_left_separator="#[fg=$thm_gray,bg=default,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$thm_gray,bg=default]$window_right_separator"
fi
fi
if [ "$fill" = "all" ]; then
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"
if [ "$status_connect_separator" = "yes" ]; then
local show_left_separator="#[fg=$color,bg=$thm_bg,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=$thm_bg]$window_right_separator"
else
local show_left_separator="#[fg=$color,bg=default,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=default]$window_right_separator"
fi
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
if [ "$status_connect_separator" = "yes" ]; 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"
else
local show_left_separator="#[fg=$background,bg=default,nobold,nounderscore,noitalics]$window_left_separator"
local show_right_separator="#[fg=$color,bg=default]$window_right_separator"
fi
fi
if [ "$window_number_position" = "left" ]; then
if [ "$status_connect_separator" = "yes" ]; 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"
else
local show_right_separator="#[fg=$background,bg=default,nobold,nounderscore,noitalics]$window_right_separator"
local show_left_separator="#[fg=$color,bg=default]$window_left_separator"
fi
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"
}
prepend_separator() {
local field="$1"
echo "${field:+ $field}"
}
build_window_icon() {
# Only update `show_window_status` if it's not empty
# this module is ran twice once for current and once for default
# meaning 2 calls to build_window_icon wich will/should both return the same
# result.
if [ -z "$show_window_status" ]; then
local custom_icon_window_last \
custom_icon_window_zoom custom_icon_window_mark custom_icon_window_mark \
custom_icon_window_silent custom_icon_window_activity custom_icon_window_bell
# shellcheck disable=SC2034
local tmux_batch_options_commands=()
# shellcheck disable=SC2034
local tmux_batch_options=()
add_tmux_batch_option "@catppuccin_icon_window_last"
add_tmux_batch_option "@catppuccin_icon_window_current"
add_tmux_batch_option "@catppuccin_icon_window_zoom"
add_tmux_batch_option "@catppuccin_icon_window_mark"
add_tmux_batch_option "@catppuccin_icon_window_silent"
add_tmux_batch_option "@catppuccin_icon_window_activity"
add_tmux_batch_option "@catppuccin_icon_window_bell"
run_tmux_batch_commands
custom_icon_window_last=$(get_tmux_batch_option "@catppuccin_icon_window_last" "󰖰")
custom_icon_window_current=$(get_tmux_batch_option "@catppuccin_icon_window_current" "󰖯")
custom_icon_window_zoom=$(get_tmux_batch_option "@catppuccin_icon_window_zoom" "󰁌")
custom_icon_window_mark=$(get_tmux_batch_option "@catppuccin_icon_window_mark" "󰃀")
custom_icon_window_silent=$(get_tmux_batch_option "@catppuccin_icon_window_silent" "󰂛")
custom_icon_window_activity=$(get_tmux_batch_option "@catppuccin_icon_window_activity" "󱅫")
custom_icon_window_bell=$(get_tmux_batch_option "@catppuccin_icon_window_bell" "󰂞")
if [ "$window_status" = "icon" ]; then
# icon order: #!~[*-]MZ
show_window_status=""
show_window_status+="#{?window_activity_flag,$(prepend_separator "${custom_icon_window_activity}"),}"
show_window_status+="#{?window_bell_flag,$(prepend_separator "${custom_icon_window_bell}"),}"
show_window_status+="#{?window_silence_flag,$(prepend_separator "${custom_icon_window_silent}"),}"
show_window_status+="#{?window_active,$(prepend_separator "${custom_icon_window_current}"),}"
show_window_status+="#{?window_last_flag,$(prepend_separator "${custom_icon_window_last}"),}"
show_window_status+="#{?window_marked_flag,$(prepend_separator "${custom_icon_window_mark}"),}"
show_window_status+="#{?window_zoomed_flag,$(prepend_separator "${custom_icon_window_zoom}"),}"
elif [ "$window_status" = "text" ]; then
show_window_status=" #F"
fi
fi
echo "$show_window_status"
}

View File

@@ -0,0 +1,72 @@
# User Defined Modules
This folder is used to store user defined modules. You can use this folder to
add a new module or override any existing module. To override an existing
module, make sure that you use the same name for your module as the module you
want to override. You can also override the window module for the current and
default window.
## Creating A New Module
> [!NOTE]
> Changes will only be applied after reloading your Tmux configuration by executing `tmux source-file ~/.tmux.conf`.
You can create a custom module by following the steps outlined below. This can be something you create entirely by yourself or integrating an existing Tmux plugin.
1. Create a new file in `~/.tmux/plugins/tmux/custom/<module_name>.sh` to store the custom module.
- The file **must** end in `.sh`
- The file **does not** need to be set as executable.
2. Copy the following template to this new file. Make sure to replace every instance of `<module_name>` by the name you chose as filename.
```bash
# If this module depends on an external Tmux plugin, say so in a comment.
# E.g.: Requires https://github.com/aaronpowell/tmux-weather
show_<module_name>() { # This function name must match the module name!
local index icon color text module
index=$1 # This variable is used internally by the module loader in order to know the position of this module
icon="$( get_tmux_option "@catppuccin_<module_name>_icon" "" )"
color="$( get_tmux_option "@catppuccin_<module_name>_color" "$thm_orange" )"
text="$( get_tmux_option "@catppuccin_<module_name>_text" "hello world" )"
module=$( build_status_module "$index" "$icon" "$color" "$text" )
echo "$module"
}
```
3. Add the custom module to the list of modules in `.tmux.conf`
```bash
set -g @catppuccin_status_modules_right "... <module_name> ..."
```
## Customization
Change the icon to one from [Nerd Fonts](https://www.nerdfonts.com/cheat-sheet).
Change the color to one of the [official colors](../catppuccin-macchiato.tmuxtheme), for instance `"$thm_cyan"`, or to a hexadecimal color like `"#00ff00"`.
The text to display can either be:
- A static text, e.g. `"hello world"`.
- The output of a command, e.g. `"#( date +%T )"`.
- The output of a script, e.g. `"#( $HOME/my_script.sh )"` . Any script will do, e.g. a Bash or Python script that prints some text, but ensure that it is executable: `chmod u+x my_script.sh`.
- An existing Tmux plugin, e.g. `" #{forecast} "` for the [Tmux Weather plugin](https://github.com/aaronpowell/tmux-weather).
Note that the icon and the color can be generated dynamically as well, for instance by having a Bash script `echo` a hexadecimal color.
To modify how often the modules are updated, add the following to `.tmux.conf`:
```tmux
set -g status-interval <number of seconds>
```
To configure a custom path for your modules, set this option:
```tmux
set -g @catppuccin_custom_plugin_dir "<path>"
```

View File

@@ -0,0 +1,16 @@
# If this module depends on an external Tmux plugin, say so in a comment.
# E.g.: Requires https://github.com/aaronpowell/tmux-weather
show_test() { # This function name must match the module name!
local index icon color text module
index=$1 # This variable is used internally by the module loader in order to know the position of this module
icon="$( get_tmux_option "@catppuccin_test_icon" "" )"
color="$( get_tmux_option "@catppuccin_test_color" "$thm_orange" )"
text="$( get_tmux_option "@catppuccin_test_text" "hello world" )"
module=$( build_status_module "$index" "$icon" "$color" "$text" )
echo "$module"
}

View File

@@ -0,0 +1,24 @@
show_pane_default_format() {
local number color background text fill
# shellcheck disable=SC2034
local tmux_batch_options_commands=()
# shellcheck disable=SC2034
local tmux_batch_options=()
add_tmux_batch_option "@catppuccin_pane_color"
add_tmux_batch_option "@catppuccin_pane_background_color"
add_tmux_batch_option "@catppuccin_pane_default_text"
add_tmux_batch_option "@catppuccin_pane_default_fill"
run_tmux_batch_commands
number="#{pane_index}"
color="$(get_tmux_batch_option "@catppuccin_pane_color" "$thm_green")"
background="$(get_tmux_batch_option "@catppuccin_pane_background_color" "$thm_gray")"
text="$(get_tmux_batch_option "@catppuccin_pane_default_text" "#{b:pane_current_path}")"
fill="$(get_tmux_batch_option "@catppuccin_pane_default_fill" "number")" # number, all, none
default_pane_format=$(build_pane_format "$number" "$color" "$background" "$text" "$fill")
echo "$default_pane_format"
}

View File

@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>catppuccin/renovate-config"
]
}

View File

@@ -0,0 +1,15 @@
show_application() {
local index icon color text module
tmux_batch_setup_status_module "application"
run_tmux_batch_commands
index=$1
icon=$(get_tmux_batch_option "@catppuccin_application_icon" "")
color=$(get_tmux_batch_option "@catppuccin_application_color" "$thm_pink")
text=$(get_tmux_batch_option "@catppuccin_application_text" "#{pane_current_command}")
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,30 @@
show_battery() {
local index icon color text module
tmux_batch_setup_status_module "battery"
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier8 󰁹 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier7 󰂁 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier6 󰁿 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier5 󰁾 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier4 󰁽 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier3 󰁼 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier2 󰁻 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_charge_tier1 󰁺 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_charged 󰚥 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_charging 󰂄 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_discharging 󰂃 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_unknown 󰂑 ;")
tmux_batch_options_commands+=("set-option -gq @batt_icon_status_attached 󱈑 ;")
run_tmux_batch_commands
index=$1
icon=$(get_tmux_batch_option "@catppuccin_battery_icon" "#{battery_icon}")
color=$(get_tmux_batch_option "@catppuccin_battery_color" "$thm_yellow")
text=$(get_tmux_batch_option "@catppuccin_battery_text" "#{battery_percentage}")
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,16 @@
# Requires https://github.com/vascomfnunes/tmux-clima
show_clima() {
local index icon color text module
tmux_batch_setup_status_module "clima"
run_tmux_batch_commands
index=$1
icon="$(get_tmux_batch_option "@catppuccin_clima_icon" "")"
color="$(get_tmux_batch_option "@catppuccin_clima_color" "$thm_yellow")"
text="$(get_tmux_batch_option "@catppuccin_clima_text" "#{clima}")"
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,20 @@
show_cpu() {
local index icon color text module
tmux_batch_setup_status_module "cpu"
tmux_batch_options_commands+=("set-option -gq @cpu_low_bg_color $thm_yellow ;") # background color when cpu is low
tmux_batch_options_commands+=("set-option -gq @cpu_medium_bg_color $thm_orange ;") # background color when cpu is medium
tmux_batch_options_commands+=("set-option -gq @cpu_high_bg_color $thm_red ;") # background color when cpu is high
run_tmux_batch_commands
index=$1
icon=$(get_tmux_batch_option "@catppuccin_cpu_icon" "")
color="$(get_tmux_batch_option "@catppuccin_cpu_color" "#{cpu_bg_color}")"
text="$(get_tmux_batch_option "@catppuccin_cpu_text" "#{cpu_percentage}")"
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,15 @@
show_date_time() {
local index icon color text module
tmux_batch_setup_status_module "date_time"
run_tmux_batch_commands
index=$1
icon="$(get_tmux_batch_option "@catppuccin_date_time_icon" "󰃰")"
color="$(get_tmux_batch_option "@catppuccin_date_time_color" "$thm_blue")"
text="$(get_tmux_batch_option "@catppuccin_date_time_text" "%Y-%m-%d %H:%M")"
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,15 @@
show_directory() {
local index icon color text module
tmux_batch_setup_status_module "directory"
run_tmux_batch_commands
index=$1
icon=$(get_tmux_batch_option "@catppuccin_directory_icon" "")
color=$(get_tmux_batch_option "@catppuccin_directory_color" "$thm_pink")
text=$(get_tmux_batch_option "@catppuccin_directory_text" "#{b:pane_current_path}")
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,17 @@
# Requires https://github.com/arl/gitmux
show_gitmux() {
local index icon color text module
tmux_batch_setup_status_module "gitmux"
run_tmux_batch_commands
index=$1
icon="$(get_tmux_batch_option "@catppuccin_gitmux_icon" "󰊢")"
color="$(get_tmux_batch_option "@catppuccin_gitmux_color" "$thm_green")"
text="$(get_tmux_batch_option "@catppuccin_gitmux_text" "#(gitmux \"#{pane_current_path}\")")"
module=$( build_status_module "$index" "$icon" "$color" "$text" )
echo "$module"
}

View File

@@ -0,0 +1,15 @@
show_host() {
local index icon color text module
tmux_batch_setup_status_module "host"
run_tmux_batch_commands
index=$1
icon=$(get_tmux_batch_option "@catppuccin_host_icon" "󰒋")
color=$(get_tmux_batch_option "@catppuccin_host_color" "$thm_magenta")
text=$(get_tmux_batch_option "@catppuccin_host_text" "#H")
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,24 @@
# Requires https://github.com/jonmosco/kube-tmux
show_kube() {
local index icon color text context_color namespace_color symbol_enabled module
tmux_batch_setup_status_module "kube"
add_tmux_batch_option "@catppuccin_kube_context_color"
add_tmux_batch_option "@catppuccin_kube_namespace_color"
run_tmux_batch_commands
index=$1
icon=$(get_tmux_batch_option "@catppuccin_kube_icon" "󱃾")
color=$(get_tmux_batch_option "@catppuccin_kube_color" "$thm_blue")
context_color=$(get_tmux_batch_option "@catppuccin_kube_context_color" "#{thm_red}")
namespace_color=$(get_tmux_batch_option "@catppuccin_kube_namespace_color" "#{thm_cyan}")
symbol_enabled=${KUBE_TMUX_SYMBOL_ENABLE:-false}
text=$(get_tmux_batch_option "@catppuccin_kube_text" "#(KUBE_TMUX_SYMBOL_ENABLE=$symbol_enabled \${TMUX_PLUGIN_MANAGER_PATH}kube-tmux/kube.tmux 250 '$context_color' '$namespace_color')")
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,15 @@
show_load() {
local index icon color text module
tmux_batch_setup_status_module "load"
run_tmux_batch_commands
index=$1
icon="$(get_tmux_batch_option "@catppuccin_load_icon" "󰊚")"
color="$(get_tmux_batch_option "@catppuccin_load_color" "$thm_blue")"
text="$(get_tmux_batch_option "@catppuccin_load_text" "#{load_full}")"
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,17 @@
# Requires https://github.com/olimorris/tmux-pomodoro-plus
show_pomodoro_plus() {
local index icon color text module
tmux_batch_setup_status_module "pomodoro_plus"
run_tmux_batch_commands
index=$1
icon="$( get_tmux_batch_option "@catppuccin_pomodoro_plus_icon" "" )"
color="$( get_tmux_batch_option "@catppuccin_pomodoro_plus_color" "$thm_orange" )"
text="$( get_tmux_batch_option "@catppuccin_pomodoro_plus_text" "#{pomodoro_status}" )"
module=$( build_status_module "$index" "$icon" "$color" "$text" )
echo "$module"
}

View File

@@ -0,0 +1,15 @@
show_session() {
local index icon color text module
tmux_batch_setup_status_module "session"
run_tmux_batch_commands
index=$1
icon=$(get_tmux_batch_option "@catppuccin_session_icon" "")
color=$(get_tmux_batch_option "@catppuccin_session_color" "#{?client_prefix,$thm_red,$thm_green}")
text=$(get_tmux_batch_option "@catppuccin_session_text" "#S")
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,15 @@
show_uptime() {
local index icon color text module
tmux_batch_setup_status_module "uptime"
run_tmux_batch_commands
index=$1
icon="$(get_tmux_batch_option "@catppuccin_uptime_icon" "󰔟")"
color="$(get_tmux_batch_option "@catppuccin_uptime_color" "$thm_green")"
text="$(get_tmux_batch_option "@catppuccin_uptime_text" "#(uptime | sed 's/^[^,]*up *//; s/, *[[:digit:]]* user.*//; s/ day.*, */d /; s/:/h /; s/ min//; s/$/m/')")"
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,15 @@
show_user() {
local index icon color text module
tmux_batch_setup_status_module "user"
run_tmux_batch_commands
index=$1
icon=$(get_tmux_batch_option "@catppuccin_user_icon" "")
color=$(get_tmux_batch_option "@catppuccin_user_color" "$thm_cyan")
text=$(get_tmux_batch_option "@catppuccin_user_text" "#(whoami)")
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,17 @@
# Requires https://github.com/xamut/tmux-weather.
show_weather() {
local index icon color text module
tmux_batch_setup_status_module "weather"
run_tmux_batch_commands
index=$1
icon="$(get_tmux_batch_option "@catppuccin_weather_icon" "")"
color="$(get_tmux_batch_option "@catppuccin_weather_color" "$thm_yellow")"
text="$(get_tmux_batch_option "@catppuccin_weather_text" "#{weather}")"
module=$(build_status_module "$index" "$icon" "$color" "$text")
echo "$module"
}

View File

@@ -0,0 +1,223 @@
#!/usr/bin/env bash
# Set path of script
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# import
# shellcheck source=./builder/module_builder.sh
source "${PLUGIN_DIR}/builder/module_builder.sh"
# shellcheck source=./builder/window_builder.sh
source "${PLUGIN_DIR}/builder/window_builder.sh"
# shellcheck source=./builder/pane_builder.sh
source "${PLUGIN_DIR}/builder/pane_builder.sh"
# shellcheck source=./utils/tmux_utils.sh
source "${PLUGIN_DIR}/utils/tmux_utils.sh"
# shellcheck source=./utils/interpolate_utils.sh
source "${PLUGIN_DIR}/utils/interpolate_utils.sh"
# shellcheck source=./utils/module_utils.sh
source "${PLUGIN_DIR}/utils/module_utils.sh"
main() {
# Aggregate all commands in one array
local tmux_commands=()
# Aggregate all tmux option for tmux_batch_option
local tmux_batch_options_commands=()
local tmux_batch_options=()
# Batch options for loading the colorscheme and everyting before
add_tmux_batch_option "@catppuccin_custom_plugin_dir"
add_tmux_batch_option "@catppuccin_flavor"
run_tmux_batch_commands
# module directories
local custom_path modules_custom_path modules_status_path modules_window_path modules_pane_path
custom_path="$(get_tmux_batch_option "@catppuccin_custom_plugin_dir" "${PLUGIN_DIR}/custom")"
modules_custom_path=$custom_path
modules_status_path=$PLUGIN_DIR/status
modules_window_path=$PLUGIN_DIR/window
modules_pane_path=$PLUGIN_DIR/pane
# load local theme
local theme
local color_interpolation=()
local color_values=()
local temp
theme="$(get_tmux_batch_option "@catppuccin_flavor" "")"
# NOTE: For backwards compatibility remove before 1.0.0 and set default for
# `@catppuccin_flavor` from `""` to `"mocha"`
if [ -z "$theme" ]; then
theme="$(get_tmux_option "@catppuccin_flavour" "")"
if [ -n "$theme" ]; then
tmux_echo "catppuccin warning: \\\"@catppuccin_flavour\\\" has been deprecated use \\\"@catppuccin_flavor\\\"" 103
else
theme="mocha"
fi
fi
# NOTE: Pulling in the selected theme by the theme that's being set as local
# variables.
# https://github.com/dylanaraps/pure-sh-bible#parsing-a-keyval-file
# shellcheck source=./catppuccin-frappe.tmuxtheme
while IFS='=' read -r key val; do
# Skip over lines containing comments.
# (Lines starting with '#').
[ "${key##\#*}" ] || continue
# '$key' stores the key.
# '$val' stores the value.
eval "local $key"="$val"
# TODO: Find a better way to strip the quotes from `$val`
temp="${val%\"}"
temp="${temp#\"}"
color_interpolation+=("\#{$key}")
color_values+=("${temp}")
done <"${PLUGIN_DIR}/themes/catppuccin_${theme}.tmuxtheme"
# Batch options for `./catppuccin.tmux`
add_tmux_batch_option "@catppuccin_status_default"
add_tmux_batch_option "@catppuccin_status_justify"
add_tmux_batch_option "@catppuccin_status_background"
add_tmux_batch_option "@catppuccin_menu_style"
add_tmux_batch_option "@catppuccin_menu_selected_style"
add_tmux_batch_option "@catppuccin_menu_border_style"
add_tmux_batch_option "@catppuccin_pane_status_enabled"
add_tmux_batch_option "@catppuccin_pane_border_status"
add_tmux_batch_option "@catppuccin_pane_border_style"
add_tmux_batch_option "@catppuccin_pane_active_border_style"
add_tmux_batch_option "@catppuccin_pane_left_separator"
add_tmux_batch_option "@catppuccin_pane_middle_separator"
add_tmux_batch_option "@catppuccin_pane_right_separator"
add_tmux_batch_option "@catppuccin_pane_number_position"
add_tmux_batch_option "@catppuccin_window_separator"
add_tmux_batch_option "@catppuccin_window_left_separator"
add_tmux_batch_option "@catppuccin_window_right_separator"
add_tmux_batch_option "@catppuccin_window_middle_separator"
add_tmux_batch_option "@catppuccin_window_number_position"
add_tmux_batch_option "@catppuccin_window_status"
add_tmux_batch_option "@catppuccin_status_left_separator"
add_tmux_batch_option "@catppuccin_status_middle_separator"
add_tmux_batch_option "@catppuccin_status_right_separator"
add_tmux_batch_option "@catppuccin_status_connect_separator"
add_tmux_batch_option "@catppuccin_status_fill"
add_tmux_batch_option "@catppuccin_status_modules_left"
add_tmux_batch_option "@catppuccin_status_modules_right"
run_tmux_batch_commands
# status general
local status_default status_justify status_background message_background
status_default=$(get_tmux_batch_option "@catppuccin_status_default" "on")
# shellcheck disable=SC2121
set status "$status_default"
status_justify=$(get_tmux_batch_option "@catppuccin_status_justify" "left")
set status-justify "$status_justify"
status_background=$(get_tmux_batch_option "@catppuccin_status_background" "theme")
if [ "${status_background}" = "theme" ]; then
set status-bg "${thm_bg}"
message_background="${thm_gray}"
else
if [ "${status_background}" = "default" ]; then
set status-style bg=default
message_background="default"
else
message_background="$(do_color_interpolation "$status_background")"
set status-bg "${message_background}"
fi
fi
set status-left-length "100"
set status-right-length "100"
# messages
set message-style "fg=${thm_cyan},bg=${message_background},align=centre"
set message-command-style "fg=${thm_cyan},bg=${message_background},align=centre"
# menu
local menu_style menu_selected_style menu_border_style
menu_style=$(get_interpolated_tmux_batch_option "@catppuccin_menu_style" "default")
menu_selected_style=$(get_interpolated_tmux_batch_option "@catppuccin_menu_selected_style" "fg=${thm_gray},bg=${thm_yellow}")
menu_border_style=$(get_interpolated_tmux_batch_option "@catppuccin_menu_border_style" "default")
set menu-style "$menu_style"
set menu-selected-style "$menu_selected_style"
set menu-border-style "$menu_border_style"
# panes
local pane_border_status pane_border_style \
pane_active_border_style pane_left_separator pane_middle_separator \
pane_right_separator pane_number_position pane_format
pane_status_enable=$(get_tmux_batch_option "@catppuccin_pane_status_enabled" "no") # yes
pane_border_status=$(get_tmux_batch_option "@catppuccin_pane_border_status" "off") # bottom
pane_border_style=$(
get_interpolated_tmux_batch_option "@catppuccin_pane_border_style" "fg=${thm_gray}"
)
pane_active_border_style=$(
get_interpolated_tmux_batch_option "@catppuccin_pane_active_border_style" \
"#{?pane_in_mode,fg=${thm_yellow},#{?pane_synchronized,fg=${thm_magenta},fg=${thm_orange}}}"
)
pane_left_separator=$(get_tmux_batch_option "@catppuccin_pane_left_separator" "█")
pane_middle_separator=$(get_tmux_batch_option "@catppuccin_pane_middle_separator" "█")
pane_right_separator=$(get_tmux_batch_option "@catppuccin_pane_right_separator" "█")
pane_number_position=$(get_tmux_batch_option "@catppuccin_pane_number_position" "left") # right, left
pane_format=$(load_modules "pane_default_format" "$modules_custom_path" "$modules_pane_path")
setw pane-border-status "$pane_border_status"
setw pane-active-border-style "$pane_active_border_style"
setw pane-border-style "$pane_border_style"
setw pane-border-format "$(do_color_interpolation "$pane_format")"
# window
local window_status_separator window_left_separator window_right_separator \
window_middle_separator window_number_position window_status_enable \
window_format window_current_format
window_status_separator=$(get_interpolated_tmux_batch_option "@catppuccin_window_separator" "")
setw window-status-separator "$window_status_separator"
window_left_separator=$(get_tmux_batch_option "@catppuccin_window_left_separator" "█")
window_right_separator=$(get_tmux_batch_option "@catppuccin_window_right_separator" "█")
window_middle_separator=$(get_tmux_batch_option "@catppuccin_window_middle_separator" "█ ")
window_number_position=$(get_tmux_batch_option "@catppuccin_window_number_position" "left") # right, left
# NOTE: update default to `"no"` when removing the backwards compatibility for
# `@catppuccin_window_status_enable` and
# `@catppuccin_window_status_icon_enable` in ./builder/window_builder.sh
window_status=$(get_tmux_batch_option "@catppuccin_window_status" "no") # no, icon, text
window_format=$(load_modules "window_default_format" "$modules_custom_path" "$modules_window_path")
setw window-status-format "$(do_color_interpolation "$window_format")"
window_current_format=$(load_modules "window_current_format" "$modules_custom_path" "$modules_window_path")
setw window-status-current-format "$(do_color_interpolation "$window_current_format")"
# status module
local status_left_separator status_middle_separator status_right_separator status_connect_separator \
status_fill status_modules_left status_modules_right
status_left_separator=$(get_tmux_batch_option "@catppuccin_status_left_separator" "")
status_right_separator=$(get_tmux_batch_option "@catppuccin_status_right_separator" "█")
status_middle_separator=$(get_tmux_batch_option "@catppuccin_status_middle_separator" "")
status_connect_separator=$(get_tmux_batch_option "@catppuccin_status_connect_separator" "yes")
status_fill=$(get_tmux_batch_option "@catppuccin_status_fill" "icon")
status_modules_left=$(get_tmux_batch_option "@catppuccin_status_modules_left" "")
loaded_modules_left=$(load_modules "$status_modules_left" "$modules_custom_path" "$modules_status_path")
set status-left "$(do_color_interpolation "$loaded_modules_left")"
status_modules_right=$(get_tmux_batch_option "@catppuccin_status_modules_right" "application session")
loaded_modules_right=$(load_modules "$status_modules_right" "$modules_custom_path" "$modules_status_path")
set status-right "$(do_color_interpolation "$loaded_modules_right")"
# modes
setw clock-mode-colour "${thm_blue}"
setw mode-style "fg=${thm_pink} bg=${thm_black4} bold"
tmux "${tmux_commands[@]}"
}
main "$@"

View File

@@ -0,0 +1,17 @@
# NOTE: you can use vars with $<var> and ${<var>} as long as the str is double quoted: ""
# WARNING: hex colors can't contain capital letters
# --> Adwaita
thm_bg="#1f1f1f"
thm_fg="#ffffff"
thm_cyan="#2aa1b3"
thm_black="#242424"
thm_gray="#303030"
thm_magenta="#a347ba"
thm_pink="#a347ba"
thm_red="#c01c28"
thm_green="#26a269"
thm_yellow="#a2734c"
thm_blue="#2a7bde"
thm_orange="#a2734c"
thm_black4="#1f1f1f"

View File

@@ -0,0 +1,25 @@
---
whiskers:
version: "2.1.1"
matrix:
- flavor
filename: "themes/catppuccin_{{flavor.identifier}}.tmuxtheme"
---
{%- set palette = flavor.colors -%}
# NOTE: you can use vars with $<var> and ${<var>} as long as the str is double quoted: ""
# WARNING: hex colors can't contain capital letters
# --> Catppuccin ({{ flavor.identifier | capitalize }})
thm_bg="#{{ palette.base.hex | lower }}"
thm_fg="#{{ palette.text.hex | lower }}"
thm_cyan="#{{ palette.sky.hex| lower }}"
thm_black="#{{ palette.mantle.hex | lower }}"
thm_gray="#{{ palette.surface0.hex | lower }}"
thm_magenta="#{{ palette.mauve.hex | lower }}"
thm_pink="#{{ palette.pink.hex | lower }}"
thm_red="#{{ palette.red.hex | lower }}"
thm_green="#{{ palette.green.hex | lower }}"
thm_yellow="#{{ palette.yellow.hex | lower }}"
thm_blue="#{{ palette.blue.hex | lower }}"
thm_orange="#{{ palette.peach.hex | lower }}"
thm_black4="#{{ palette.surface2.hex | lower }}"

View File

@@ -0,0 +1,11 @@
#!/bin/sh
do_color_interpolation() {
local all_interpolated="$1"
for ((i=0; i<${#color_interpolation[@]}; i++)); do
all_interpolated=${all_interpolated//${color_interpolation[$i]}/${color_values[$i]}}
done
echo "$all_interpolated"
}

View File

@@ -0,0 +1,51 @@
#!/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
# shellcheck source=/dev/null
source "$module_path"
loaded_modules="$loaded_modules$( "show_$module_name" "$module_index" )"
module_index+=1
continue 2
fi
done
if [[ -z "${module_name/ }" ]]; then
if [[ -z "${modules_list/ }" ]]; then
tmux_echo "catppuccin warning: a module list has only white space, to remove all modules set it to \\\"null\\\"" 100
else
tmux_echo "catppuccin warning: a module list with value \\\"$modules_list\\\" has leading/trailing whitespace" 101
fi
continue
fi
tmux_echo "catppuccin warning: module $module_name not found" 102
done
echo "$loaded_modules"
}

View File

@@ -0,0 +1,151 @@
#!/bin/sh
tmux_echo() {
local hook
hook="after-new-session[$2]"
tmux set-hook -g "$hook" "run-shell 'echo -e \"$1\"'; set-hook -gu \"$hook\""
}
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
}
get_interpolated_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
do_color_interpolation "$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" ";")
}
get_tmux_batch_option() {
local option default value
option="$1"
default="$2"
for option_index in "${!tmux_batch_options[@]}"; do
IFS="" read -r read_option read_value <<<"${tmux_batch_options[$option_index]}"
if [[ "$read_option" == "$option" ]]; then
echo "$read_value"
return
fi
done
echo "$default"
}
get_interpolated_tmux_batch_option() {
local option default value
option="$1"
default="$2"
for option_index in "${!tmux_batch_options[@]}"; do
IFS="" read -r read_option read_value <<<"${tmux_batch_options[$option_index]}"
if [[ "$read_option" == "$option" ]]; then
do_color_interpolation "$read_value"
return
fi
done
echo "$default"
}
add_tmux_batch_option() {
local option
option="$1"
tmux_batch_options_commands+=("show-option -gq $option ;")
}
set_tmux_batch_option() {
local option value
option="$1"
value="$2"
# NOTE: don't check for duplicates just append
# for option_index in "${!tmux_batch_options[@]}"; do
# read -d '' -r read_option <<<"${tmux_batch_options[$option_index]}"
# if [[ "$read_option" == "$option" ]]; then
# tmux_batch_options["$option_index"]="$option$value"
# return
# fi
# done
tmux_batch_options+=("$option$value")
}
run_tmux_batch_commands() {
local temp
# shellcheck disable=SC2048,SC2086,SC2162
while IFS=' ' read option value; do
if [ -n "$value" ]; then
if [ "$value" = "null" ]; then
set_tmux_batch_option "$option" ""
else
temp="${value%\"}"
temp="${temp#\"}"
set_tmux_batch_option "$option" "$temp"
fi
fi
done < <(tmux ${tmux_batch_options_commands[*]})
tmux_batch_options_commands=()
}
tmux_batch_setup_status_module() {
local name="$1"
# Don't want to run commands set before since we can't update
# `tmux_batch_options` for it
# shellcheck disable=SC2034
tmux_batch_options_commands=()
# No need to check previous options
# shellcheck disable=SC2034
tmux_batch_options=()
add_tmux_batch_option "@catppuccin_${name}_icon"
add_tmux_batch_option "@catppuccin_${name}_color"
add_tmux_batch_option "@catppuccin_${name}_text"
}

View File

@@ -0,0 +1,24 @@
show_window_current_format() {
local number color background text fill current_window_format
# shellcheck disable=SC2034
local tmux_batch_options_commands=()
# shellcheck disable=SC2034
local tmux_batch_options=()
add_tmux_batch_option "@catppuccin_window_current_color"
add_tmux_batch_option "@catppuccin_window_current_background"
add_tmux_batch_option "@catppuccin_window_current_text"
add_tmux_batch_option "@catppuccin_window_current_fill"
run_tmux_batch_commands
number="#I"
color=$(get_tmux_batch_option "@catppuccin_window_current_color" "$thm_orange")
background=$(get_tmux_batch_option "@catppuccin_window_current_background" "$thm_bg")
text="$(get_tmux_batch_option "@catppuccin_window_current_text" "#{b:pane_current_path}")" # use #W for application instead of directory
fill="$(get_tmux_batch_option "@catppuccin_window_current_fill" "number")" # number, all, none
current_window_format=$(build_window_format "$number" "$color" "$background" "$text" "$fill" "current")
echo "$current_window_format"
}

View File

@@ -0,0 +1,24 @@
show_window_default_format() {
local number color background text fill default_window_format
# shellcheck disable=SC2034
local tmux_batch_options_commands=()
# shellcheck disable=SC2034
local tmux_batch_options=()
add_tmux_batch_option "@catppuccin_window_default_color"
add_tmux_batch_option "@catppuccin_window_default_background"
add_tmux_batch_option "@catppuccin_window_default_text"
add_tmux_batch_option "@catppuccin_window_default_fill"
run_tmux_batch_commands
number="#I"
color=$(get_tmux_batch_option "@catppuccin_window_default_color" "$thm_blue")
background=$(get_tmux_batch_option "@catppuccin_window_default_background" "$thm_gray")
text="$(get_tmux_batch_option "@catppuccin_window_default_text" "#{b:pane_current_path}")" # use #W for application instead of directory
fill="$(get_tmux_batch_option "@catppuccin_window_default_fill" "number")" # number, all, none
default_window_format=$(build_window_format "$number" "$color" "$background" "$text" "$fill" "default")
echo "$default_window_format"
}