diff --git a/functions/__config_settings_draw.fish b/functions/__config_settings_draw.fish index 1d28444..6518ddd 100644 --- a/functions/__config_settings_draw.fish +++ b/functions/__config_settings_draw.fish @@ -38,13 +38,7 @@ function __config_settings_draw set -l cur_scope $argv[2] set -l vars $argv[3..] - set -l c_ok (set_color green) - set -l c_err (set_color red) - set -l c_dim (set_color brblack) - set -l c_sel (set_color --bold magenta) - set -l c_hi (set_color --bold white) - set -l c_head (set_color --bold cyan) - set -l c_reset (set_color normal) + __fish_palette set -l labels Aliases Auto-exec Overrides Integrations Logging Greeting Master diff --git a/functions/__config_settings_draw_subcat.fish b/functions/__config_settings_draw_subcat.fish index c7dccd3..e9ef166 100644 --- a/functions/__config_settings_draw_subcat.fish +++ b/functions/__config_settings_draw_subcat.fish @@ -41,12 +41,7 @@ function __config_settings_draw_subcat set -l cur_scope $argv[2] set -l category_var $argv[3] - set -l c_ok (set_color green) - set -l c_err (set_color red) - set -l c_dim (set_color brblack) - set -l c_sel (set_color --bold magenta) - set -l c_head (set_color --bold cyan) - set -l c_reset (set_color normal) + __fish_palette set -l rows (__config_settings_subcats $category_var) set -l n (count $rows) diff --git a/functions/__config_settings_draw_value.fish b/functions/__config_settings_draw_value.fish index f315056..98237e4 100644 --- a/functions/__config_settings_draw_value.fish +++ b/functions/__config_settings_draw_value.fish @@ -33,12 +33,7 @@ function __config_settings_draw_value set -l edit_mode $argv[3] set -l edit_buf $argv[4] - set -l c_ok (set_color green) - set -l c_err (set_color red) - set -l c_dim (set_color brblack) - set -l c_sel (set_color --bold magenta) - set -l c_head (set_color --bold cyan) - set -l c_reset (set_color normal) + __fish_palette # ── Page row metadata (parallel lists) ──────────────────────────────── set -l title diff --git a/functions/__config_settings_pagetab.fish b/functions/__config_settings_pagetab.fish index 024ce01..b9d5a49 100644 --- a/functions/__config_settings_pagetab.fish +++ b/functions/__config_settings_pagetab.fish @@ -27,8 +27,7 @@ function __config_settings_pagetab set -l active $argv[1] set -l iw $argv[2] - set -l c_hi (set_color --bold white) - set -l c_reset (set_color normal) + __fish_palette set -l names Universal Session Sponge Paths set -l strip ' ' diff --git a/functions/__fish_palette.fish b/functions/__fish_palette.fish new file mode 100644 index 0000000..7097f39 --- /dev/null +++ b/functions/__fish_palette.fish @@ -0,0 +1,63 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later + +# SYNOPSIS +# __fish_palette +# +# DESCRIPTION +# Defines the shared terminal-output colour roles used by the +# user-facing functions in this configuration. Declared +# --no-scope-shadowing and using a bare `set`, so the variables are +# created in the CALLER's scope -- a consumer just calls it and then +# interpolates $c_head, $c_err and friends exactly as it did when the +# declarations were inline. +# +# Call it where the local declarations used to sit, once per contiguous +# block that needs the palette. set_color runs at call time, so the +# values track $TERM exactly as inline declarations did. (Measured: +# set_color output is identical across every TERM tested except +# TERM=dumb, which yields empty strings, and is unaffected by whether +# stdout is a tty or a pipe.) +# +# A role is a semantic slot, not a colour. c_flag and c_warn are both +# yellow but stay separate, as do c_ok and c_accent (both green) -- +# merging either pair would foreclose ever restyling one without the +# other. c_accent is the command name in logs and smart_exit, which +# style it green where the rest of the config styles it bold. +# +# ARGUMENTS +# none +# +# EXIT STATUS +# 0 always +# +# EXAMPLE +# function mytool +# __fish_palette +# echo "$c_head""Usage:$c_reset $c_cmd""mytool$c_reset" +# end +# +# NOTES +# Calling this at top level (outside any function) creates GLOBAL +# variables. Every consumer calls it from inside a function, where the +# variables stay function-local and do not leak. +# +# functions/fish_prompt.fish deliberately does NOT use this palette. Its +# c_* values are Catppuccin hex strings passed as ARGUMENTS to set_color +# (`set_color --bold $c_green`), not captured escape sequences -- colour +# inputs rather than rendered output, a different concern. + +function __fish_palette --no-scope-shadowing --description 'Define the shared output colour palette in the caller scope' + set c_reset (set_color normal) + set c_head (set_color --bold cyan) + set c_cmd (set_color --bold) + set c_arg (set_color cyan) + set c_flag (set_color yellow) + set c_warn (set_color yellow) + set c_err (set_color red) + set c_ok (set_color green) + set c_accent (set_color green) + set c_dim (set_color brblack) + set c_sel (set_color --bold magenta) + set c_hi (set_color --bold white) +end diff --git a/functions/_agents_init_ensure_gitignore.fish b/functions/_agents_init_ensure_gitignore.fish index 45d4c9f..f8b9ee3 100644 --- a/functions/_agents_init_ensure_gitignore.fish +++ b/functions/_agents_init_ensure_gitignore.fish @@ -31,8 +31,7 @@ # EXAMPLE # _agents_init_ensure_gitignore /home/user/myproject "agents-init" "AGENTS/" "/AGENTS.md" function _agents_init_ensure_gitignore - set -l c_ok (set_color green) - set -l c_reset (set_color normal) + __fish_palette if test (count $argv) -lt 3 echo (set_color red)"_agents_init_ensure_gitignore: requires