From a2dda02b43194aec5deddf2890c28c76b4c11ed4 Mon Sep 17 00:00:00 2001 From: vdbe <44153531+vdbe@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:44:19 +0000 Subject: [PATCH] feat: error/warning messages on first load (#278) `tmux_echo` now uses hooks this allows it to print on the first load. To cleanup the hooks every hook gets a _unique_ number/index, this is _not_ enforced. --- utils/module_utils.sh | 6 +++--- utils/tmux_utils.sh | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/utils/module_utils.sh b/utils/module_utils.sh index 8362780..8dd2a7e 100644 --- a/utils/module_utils.sh +++ b/utils/module_utils.sh @@ -35,14 +35,14 @@ load_modules() { 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\"" + 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" + 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" + tmux_echo "catppuccin warning: module $module_name not found" 102 done diff --git a/utils/tmux_utils.sh b/utils/tmux_utils.sh index 5987441..7aa3151 100644 --- a/utils/tmux_utils.sh +++ b/utils/tmux_utils.sh @@ -1,8 +1,10 @@ #!/bin/sh tmux_echo() { - local message="$1" - tmux run-shell "echo '$message'" + local hook + hook="after-new-session[$2]" + + tmux set-hook -g "$hook" "run-shell 'echo \"$1\"'; set-hook -gu \"$hook\"" } get_tmux_option() {