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.
This commit is contained in:
vdbe 2024-08-05 14:44:19 +00:00 committed by GitHub
parent 362a306db7
commit a2dda02b43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -35,14 +35,14 @@ load_modules() {
if [[ -z "${module_name/ }" ]]; then if [[ -z "${module_name/ }" ]]; then
if [[ -z "${modules_list/ }" ]]; 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 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 fi
continue continue
fi fi
tmux_echo "catppuccin warning: module $module_name not found" tmux_echo "catppuccin warning: module $module_name not found" 102
done done

View file

@ -1,8 +1,10 @@
#!/bin/sh #!/bin/sh
tmux_echo() { tmux_echo() {
local message="$1" local hook
tmux run-shell "echo '$message'" hook="after-new-session[$2]"
tmux set-hook -g "$hook" "run-shell 'echo \"$1\"'; set-hook -gu \"$hook\""
} }
get_tmux_option() { get_tmux_option() {