From 96c033d0730c96c4a8de6176cbd8591e83b722b5 Mon Sep 17 00:00:00 2001 From: K H Soh Date: Tue, 1 Oct 2024 21:37:16 +0800 Subject: [PATCH 1/6] Added missing pane right separator setting --- catppuccin_tmux.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/catppuccin_tmux.conf b/catppuccin_tmux.conf index a9650fef..7d277011 100644 --- a/catppuccin_tmux.conf +++ b/catppuccin_tmux.conf @@ -59,7 +59,7 @@ set -wgF pane-border-style "#{E:@catppuccin_pane_border_style}" set -g @_ctp_p_middle \ "#[fg=#{@thm_fg},bg=#{@thm_surface_0}]#{@catppuccin_pane_middle_separator}" set -g @_ctp_p_right \ - "#[fg=#{@thm_surface_0},bg=default]#{@catppuccin_pane_middle_separator}" + "#[fg=#{@thm_surface_0},bg=default]#{@catppuccin_pane_right_separator}" set -g @_ctp_p_number \ "#[fg=#{@thm_fg},bg=#{@thm_surface_0}]##{pane_index}" @@ -71,9 +71,9 @@ set -wgF pane-border-style "#{E:@catppuccin_pane_border_style}" set -g @_ctp_p_left \ "#[fg=#{E:@catppuccin_pane_color},bg=default]#{@catppuccin_pane_left_separator}" set -g @_ctp_p_middle \ - "#[fg=#{E:@catppuccin_pane_background_color},bg=#{E:@catppuccin_pane_color}]#{@catppuccin_pane_middle_separator}" + "#[fg=#{E:@catppuccin_pane_color},bg=#{E:@catppuccin_pane_background_color}]#{@catppuccin_pane_middle_separator}" set -g @_ctp_p_right \ - "#[fg=#{E:@catppuccin_pane_color},bg=default]#{@catppuccin_pane_middle_separator}" + "#[fg=#{E:@catppuccin_pane_color},bg=default]#{@catppuccin_pane_right_separator}" set -g @_ctp_p_number \ "#[fg=#{E:@catppuccin_pane_background_color},bg=#{E:@catppuccin_pane_color}]##{pane_index}" @@ -213,7 +213,7 @@ set -ogqF @catppuccin_window_current_right_separator "#{@catppuccin_window_right "#[fg=#{E:@catppuccin_window_default_background},bg=default]#{@catppuccin_window_left_separator}" set -g @_ctp_w_right \ "#[fg=#{E:@catppuccin_window_default_color},bg=default]#{@catppuccin_window_right_separator}" - + %else set -g @_ctp_w_left \ "#[fg=#{E:@catppuccin_window_default_color},bg=default]#{@catppuccin_window_left_separator}" @@ -279,7 +279,7 @@ set -ogqF @catppuccin_window_current_right_separator "#{@catppuccin_window_right "#[fg=#{E:@catppuccin_window_current_background},bg=default]#{@catppuccin_window_current_left_separator}" set -g @_ctp_w_right \ "#[fg=#{E:@catppuccin_window_current_color},bg=default]#{@catppuccin_window_current_right_separator}" - + %else set -g @_ctp_w_left \ "#[fg=#{E:@catppuccin_window_current_color},bg=default]#{@catppuccin_window_current_left_separator}" From 17291f2a9ad03181231eea6ed61289ee6b5bd571 Mon Sep 17 00:00:00 2001 From: K H Soh Date: Tue, 1 Oct 2024 22:21:44 +0800 Subject: [PATCH 2/6] Fixed test for pane_styling.sh script --- tests/pane_styling_expected.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pane_styling_expected.txt b/tests/pane_styling_expected.txt index dfdac504..d57e36f0 100644 --- a/tests/pane_styling_expected.txt +++ b/tests/pane_styling_expected.txt @@ -1,4 +1,4 @@ pane-border-format #[fg=#a6e3a1,bg=default]█#[fg=#313244,bg=#a6e3a1]#{pane_index}#[fg=#a6e3a1,bg=#313244]█ #[fg=#a6e3a1,bg=#313244]#{b:pane_current_path}#[fg=#313244,bg=default]█ pane-border-format #[fg=#313244,bg=default]█#[fg=#a6e3a1,bg=#313244]#{b:pane_current_path} #[fg=#a6e3a1,bg=#313244]█#[fg=#313244,bg=#a6e3a1]#{pane_index}#[fg=#a6e3a1,bg=default]█ -pane-border-format #[fg=#a6e3a1,bg=default]█#[fg=#313244,bg=#a6e3a1]#{pane_index}#[fg=#313244,bg=#a6e3a1]█ #[fg=#313244,bg=#a6e3a1]#{b:pane_current_path}#[fg=#a6e3a1,bg=default]█ +pane-border-format #[fg=#a6e3a1,bg=default]█#[fg=#313244,bg=#a6e3a1]#{pane_index}#[fg=#a6e3a1,bg=#313244]█ #[fg=#313244,bg=#a6e3a1]#{b:pane_current_path}#[fg=#a6e3a1,bg=default]█ pane-border-format #[fg=#313244,bg=default]█#[fg=#cdd6f4,bg=#313244]#{pane_index}#[fg=#cdd6f4,bg=#313244]█ #[fg=#cdd6f4,bg=#313244]#{b:pane_current_path}#[fg=#313244,bg=default]█ From 6688801533e0a5ebfa924719cb993994ed1ded2b Mon Sep 17 00:00:00 2001 From: K H Soh Date: Sat, 26 Oct 2024 11:48:37 +0800 Subject: [PATCH 3/6] Added support for user-defined status modules --- catppuccin_tmux.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/catppuccin_tmux.conf b/catppuccin_tmux.conf index a4cc5403..83d70706 100644 --- a/catppuccin_tmux.conf +++ b/catppuccin_tmux.conf @@ -1,3 +1,5 @@ +set -gF @catppuccin_tmux_directory "#{d:current_file}" + source -F "#{d:current_file}/themes/catppuccin_#{@catppuccin_flavor}_tmux.conf" %if "#{==:#{@catppuccin_status_background},default}" @@ -22,6 +24,10 @@ source -F "#{d:current_file}/status/application.conf" source -F "#{d:current_file}/status/battery.conf" source -F "#{d:current_file}/status/clima.conf" source -F "#{d:current_file}/status/cpu.conf" +%if "#{!=:#{@catppuccin_user_status_directory},}" +source -F "#{E:@catppuccin_user_status_directory}/*.conf" +%endif + source -F "#{d:current_file}/status/date_time.conf" source -F "#{d:current_file}/status/directory.conf" source -F "#{d:current_file}/status/gitmux.conf" From 3839aa6e4c3eb3e0ba3e7d6abd19040b6e76195f Mon Sep 17 00:00:00 2001 From: K H Soh Date: Sat, 26 Oct 2024 12:09:53 +0800 Subject: [PATCH 4/6] Moved processing of user-defined status modules --- catppuccin_tmux.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/catppuccin_tmux.conf b/catppuccin_tmux.conf index 83d70706..07a6f5c8 100644 --- a/catppuccin_tmux.conf +++ b/catppuccin_tmux.conf @@ -24,10 +24,6 @@ source -F "#{d:current_file}/status/application.conf" source -F "#{d:current_file}/status/battery.conf" source -F "#{d:current_file}/status/clima.conf" source -F "#{d:current_file}/status/cpu.conf" -%if "#{!=:#{@catppuccin_user_status_directory},}" -source -F "#{E:@catppuccin_user_status_directory}/*.conf" -%endif - source -F "#{d:current_file}/status/date_time.conf" source -F "#{d:current_file}/status/directory.conf" source -F "#{d:current_file}/status/gitmux.conf" @@ -40,6 +36,10 @@ source -F "#{d:current_file}/status/uptime.conf" source -F "#{d:current_file}/status/user.conf" source -F "#{d:current_file}/status/weather.conf" +%if "#{!=:#{@catppuccin_user_status_directory},}" +source -F "#{E:@catppuccin_user_status_directory}/*.conf" +%endif + # messages set -gF message-style "fg=#{@thm_teal},bg=$CTP_MESSAGE_BACKGROUND,align=centre" set -gF message-command-style "fg=#{@thm_teal},bg=$CTP_MESSAGE_BACKGROUND,align=centre" From fdaa6477c3dc03005f0db1f4ba2ed6b69af411ab Mon Sep 17 00:00:00 2001 From: K H Soh Date: Mon, 28 Oct 2024 11:52:57 +0800 Subject: [PATCH 5/6] Added documentation and tests for custom status module extension --- docs/tutorials/02-custom-status.md | 52 ++++++++++++++++++++++++++---- run_tests.sh | 1 + tests/custom_status.sh | 12 +++++++ tests/custom_status_expected.txt | 1 + 4 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 tests/custom_status.sh create mode 100644 tests/custom_status_expected.txt diff --git a/docs/tutorials/02-custom-status.md b/docs/tutorials/02-custom-status.md index 618a6d58..78321e26 100644 --- a/docs/tutorials/02-custom-status.md +++ b/docs/tutorials/02-custom-status.md @@ -24,18 +24,58 @@ set -ag status-right "#[fg=#{@thm_fg},bg=#{@thm_mantle}] #(memory_pressure | awk ![Example of the custom ram module](../../assets/ram-example.webp) -To use the status module formatting that catppuccin uses, do the following: +To use the status module formatting that catppuccin uses, create a directory that contains the custom status modules. Then point `@catppuccin_user_status_directory` at that directory: ```sh -# In ~/.tmux.conf, after the catppuccin plugin has been loaded. +# In ~/.tmux.conf, before loading the catppuccin plugin +set -gF @catppuccin_user_status_directory "~/.config/tmux/custom" + +# Apply your custom module in status-right +set -g status-right "#{E:@catpuccin_status_application}#{E:@catppuccin_status_my_custom_module}" +``` + +Then in the `~/.config/tmux/custom` directory, you can create custom status modules (which must have `.conf` file extension) like this: + +```sh +# my_custom.conf %hidden MODULE_NAME="my_custom_module" -set -ogq "@catppuccin_${MODULE_NAME}_icon" " " +set -ogq "@catppuccin_${MODULE_NAME}_icon" " " set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_pink}" -set -ogq "@catppuccin_${MODULE_NAME}_text" "#{pane_current_command}" +set -ogq "@catppuccin_${MODULE_NAME}_text" "#{pane_current_command}" -source "/utils/status_module.conf" +source -F "#{@catppuccin_tmux_directory}/utils/status_module.conf" -set -g status-right "#{E:@catpuccin_status_application}#{E:@catppuccin_status_my_custom_module}" +``` + +More than one custom status module can be defined. A practical use-case is to have both CPU and RAM usage such as: +```sh +# In ~/.tmux.conf, before loading the catppuccin plugin +set -gF @catppuccin_user_status_directory "~/.config/tmux/custom" + +# Apply your custom module in status-right +set -g status-right "#{E:@catpuccin_status_application}#{E:@catppuccin_status_cpu}#{E:@catppuccin_status_ram}" +``` + +Then create `~/.config/tmux/custom/ram.conf`: + +```sh +%hidden MODULE_NAME="ram" + +set -ogq @ram_low_fg_color "#{E:@thm_fg}" +set -ogq @ram_medium_fg_color "#{E:@thm_fg}" +set -ogq @ram_high_fg_color "#{E:@thm_crust}" + +set -ogq @ram_low_bg_color "#{E:@catppuccin_status_module_text_bg}" +set -ogq @ram_medium_bg_color "#{E:@catppuccin_status_module_text_bg}" +set -ogq @ram_high_bg_color "#{E:@thm_red}" + +set -ogq "@catppuccin_${MODULE_NAME}_icon" "#{l:#{ram_icon}} " +set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_blue}" +set -ogq "@catppuccin_status_${MODULE_NAME}_text_fg" "#{l:#{ram_fg_color}}" +set -ogq "@catppuccin_status_${MODULE_NAME}_text_bg" "#{l:#{ram_bg_color}}" +set -ogq "@catppuccin_${MODULE_NAME}_text" " #{l:#{ram_percentage}}" + +source -F "#{@catppuccin_tmux_directory}/utils/status_module.conf" ``` diff --git a/run_tests.sh b/run_tests.sh index 4f3d7ed5..3cddaf04 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -10,4 +10,5 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) "${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/application_module.sh --expected "${script_dir}"/tests/application_module_expected.txt "$@" "${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/battery_module.sh --expected "${script_dir}"/tests/battery_module_expected.txt "$@" "${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/cpu_module.sh --expected "${script_dir}"/tests/cpu_module_expected.txt "$@" +"${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/custom_status.sh --expected "${script_dir}"/tests/custom_status_expected.txt "$@" "${script_dir}"/tests/harness.sh --test "${script_dir}"/tests/pane_styling.sh --expected "${script_dir}"/tests/pane_styling_expected.txt "$@" diff --git a/tests/custom_status.sh b/tests/custom_status.sh new file mode 100644 index 00000000..27f3cc67 --- /dev/null +++ b/tests/custom_status.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) +# shellcheck disable=SC1091 +source "${script_dir}/helpers.sh" + +tmux set -g @catppuccin_user_status_directory "${script_dir}/custom" +# Tests that the default options are set correctly +tmux source "${script_dir}/../catppuccin_options_tmux.conf" +tmux source "${script_dir}/../catppuccin_tmux.conf" + +print_option E:@catppuccin_status_ram diff --git a/tests/custom_status_expected.txt b/tests/custom_status_expected.txt new file mode 100644 index 00000000..9afe2908 --- /dev/null +++ b/tests/custom_status_expected.txt @@ -0,0 +1 @@ +E:@catppuccin_status_ram #[fg=#89b4fa]#[fg=#11111b,bg=#89b4fa]#{ram_icon} #[fg=#{ram_fg_color},bg=#{ram_bg_color}] #{ram_percentage}#[reverse]█#[noreverse] From 656906ac1ea8d53d74a9b9b31dddccfab537306e Mon Sep 17 00:00:00 2001 From: K H Soh Date: Mon, 28 Oct 2024 13:52:46 +0800 Subject: [PATCH 6/6] Moved custom subdirectory to avoid .gitignore filter --- tests/custom_status.sh | 2 +- tests/userdefined/ram.conf | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/userdefined/ram.conf diff --git a/tests/custom_status.sh b/tests/custom_status.sh index 27f3cc67..5be744af 100644 --- a/tests/custom_status.sh +++ b/tests/custom_status.sh @@ -4,7 +4,7 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) # shellcheck disable=SC1091 source "${script_dir}/helpers.sh" -tmux set -g @catppuccin_user_status_directory "${script_dir}/custom" +tmux set -g @catppuccin_user_status_directory "${script_dir}/userdefined" # Tests that the default options are set correctly tmux source "${script_dir}/../catppuccin_options_tmux.conf" tmux source "${script_dir}/../catppuccin_tmux.conf" diff --git a/tests/userdefined/ram.conf b/tests/userdefined/ram.conf new file mode 100644 index 00000000..aeaf9bf6 --- /dev/null +++ b/tests/userdefined/ram.conf @@ -0,0 +1,19 @@ +# vim:set ft=tmux: +%hidden MODULE_NAME="ram" + +set -ogq @ram_low_fg_color "#{E:@thm_fg}" +set -ogq @ram_medium_fg_color "#{E:@thm_fg}" +set -ogq @ram_high_fg_color "#{E:@thm_crust}" + +set -ogq @ram_low_bg_color "#{E:@catppuccin_status_module_text_bg}" +set -ogq @ram_medium_bg_color "#{E:@catppuccin_status_module_text_bg}" +set -ogq @ram_high_bg_color "#{E:@thm_red}" + +set -ogq "@catppuccin_${MODULE_NAME}_icon" "#{l:#{ram_icon}} " +set -ogqF "@catppuccin_${MODULE_NAME}_color" "#{E:@thm_blue}" +set -ogq "@catppuccin_status_${MODULE_NAME}_text_fg" "#{l:#{ram_fg_color}}" +set -ogq "@catppuccin_status_${MODULE_NAME}_text_bg" "#{l:#{ram_bg_color}}" +set -ogq "@catppuccin_${MODULE_NAME}_text" " #{l:#{ram_percentage}}" + +source -F "#{@catppuccin_tmux_directory}/utils/status_module.conf" +