From 7d815b17e83c94d33092e74222d323bbcc0fc45b Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 20:10:43 -0400 Subject: [PATCH] refactor: retire drifted palette names in the last five functions c_rst/c_txt -> c_reset, c_ttl -> c_head, c_bold -> c_cmd, c_primary -> c_arg across 67 interpolation sites (c_rst 53, c_primary 10, c_bold 2, c_ttl 1, c_txt 1). Each maps to a variable holding identical bytes, so output is unchanged. Unlike the 33 structural conversions this edits text that renders, so it is gated on its own per-file byte-diff against main: ok logs --help (431 B out, 0 B err) ok mkcd --help (437 B out, 0 B err) ok qc --help (936 B out, 0 B err) ok rand_string --help (883 B out, 0 B err) ok smart_exit --help (265 B out, 0 B err) ok mkcd (437 B out, 0 B err) <- no-args error path c_accent is deliberately NOT merged into c_ok -- both are (set_color green) but a role is a semantic slot, not a colour. See JOB-BRIEF-FINDINGS.md. logs.fish needed two calls (the C4 guard block and the --help block, both at 8-space indentation); it is the only multi-run file in the repository and the exact trap a depth-deduplicating converter falls into. logs.fish also declared c_bold without ever interpolating it -- that declaration is simply deleted. --- functions/logs.fish | 22 +++++++++------------- functions/mkcd.fish | 34 +++++++++++++--------------------- functions/qc.fish | 23 +++++++++-------------- functions/rand_string.fish | 32 ++++++++++++++------------------ functions/smart_exit.fish | 14 +++++--------- 5 files changed, 50 insertions(+), 75 deletions(-) diff --git a/functions/logs.fish b/functions/logs.fish index fe64d17..12efbf9 100644 --- a/functions/logs.fish +++ b/functions/logs.fish @@ -39,8 +39,7 @@ function logs --description 'Browse terminal log files interactively with fzf' # Opinionated guard (C4): integrations disabled if not __fish_config_op_enabled (status current-function) - set -l c_err (set_color red) - set -l c_reset (set_color normal) + __fish_palette echo "$c_err"'logs: disabled by __fish_config_op_integrations'"$c_reset" >&2 return 1 end @@ -50,24 +49,21 @@ function logs --description 'Browse terminal log files interactively with fzf' or return 1 if set -q _flag_help - set -l c_accent (set_color green) - set -l c_primary (set_color cyan) - set -l c_bold (set_color --bold) - set -l c_reset (set_color normal) - echo "Usage: "$c_accent"logs"$c_reset" ["$c_primary"OPTIONS"$c_reset"]" + __fish_palette + echo "Usage: "$c_accent"logs"$c_reset" ["$c_arg"OPTIONS"$c_reset"]" echo "" echo "Browse and open terminal log files interactively." echo "Logs sorted newest-first. Type to fuzzy-filter by date or category." echo "" echo "Options:" - echo " "$c_primary"-h, --help"$c_reset" Show this help" - echo " "$c_primary"-c, --category"$c_reset" Limit to one category: scrollback, paru, yay" + echo " "$c_arg"-h, --help"$c_reset" Show this help" + echo " "$c_arg"-c, --category"$c_reset" Limit to one category: scrollback, paru, yay" echo "" echo "Keys in fzf:" - echo " "$c_primary"Enter"$c_reset" Open in \$PAGER" - echo " "$c_primary"Ctrl-E"$c_reset" Open in \$EDITOR" - echo " "$c_primary"Ctrl-D"$c_reset" Delete selected log" - echo " "$c_primary"Ctrl-C"$c_reset" Quit" + echo " "$c_arg"Enter"$c_reset" Open in \$PAGER" + echo " "$c_arg"Ctrl-E"$c_reset" Open in \$EDITOR" + echo " "$c_arg"Ctrl-D"$c_reset" Delete selected log" + echo " "$c_arg"Ctrl-C"$c_reset" Quit" return 0 end diff --git a/functions/mkcd.fish b/functions/mkcd.fish index 3a2eac9..5cf8c30 100644 --- a/functions/mkcd.fish +++ b/functions/mkcd.fish @@ -26,31 +26,23 @@ # mkcd ~/projects/myapp # mkcd ~/projects/newapp/src function mkcd --description 'Create a directory (with parents) and cd into it' - set -l c_head (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_arg (set_color cyan) - set -l c_flag (set_color yellow) - set -l c_ok (set_color green) - set -l c_warn (set_color yellow) - set -l c_err (set_color red) - set -l c_dim (set_color brblack) - set -l c_rst (set_color normal) + __fish_palette if contains -- -h $argv; or contains -- --help $argv; or test (count $argv) -eq 0 - echo "$c_head""Usage:$c_rst $c_cmd""mkcd$c_rst $c_arg""$c_rst" + echo "$c_head""Usage:$c_reset $c_cmd""mkcd$c_reset $c_arg""$c_reset" echo - echo " Create $c_arg""$c_rst (including missing parents) and cd into it." + echo " Create $c_arg""$c_reset (including missing parents) and cd into it." echo - echo "$c_head""Arguments:$c_rst" - echo " $c_arg""$c_rst Directory to create and enter" + echo "$c_head""Arguments:$c_reset" + echo " $c_arg""$c_reset Directory to create and enter" echo - echo "$c_head""Flags:$c_rst" - echo " $c_flag-h$c_rst, $c_flag--help$c_rst Show this help message" - echo " $c_flag-s$c_rst, $c_flag--silent$c_rst Suppress directory creation output" + echo "$c_head""Flags:$c_reset" + echo " $c_flag-h$c_reset, $c_flag--help$c_reset Show this help message" + echo " $c_flag-s$c_reset, $c_flag--silent$c_reset Suppress directory creation output" echo - echo "$c_head""Examples:$c_rst" - echo " $c_cmd""mkcd$c_rst $c_arg~/projects/myapp$c_rst" - echo " $c_cmd""mkcd$c_rst $c_arg~/projects/myapp$c_rst""$c_dim""; git init$c_rst" + echo "$c_head""Examples:$c_reset" + echo " $c_cmd""mkcd$c_reset $c_arg~/projects/myapp$c_reset" + echo " $c_cmd""mkcd$c_reset $c_arg~/projects/myapp$c_reset""$c_dim""; git init$c_reset" return 0 end @@ -77,8 +69,8 @@ function mkcd --description 'Create a directory (with parents) and cd into it' or return $status if test $is_new -eq 1 - echo "$c_ok""✔$c_rst Created and entered $c_arg$dir$c_rst" + echo "$c_ok""✔$c_reset Created and entered $c_arg$dir$c_reset" else - echo "$c_warn""→$c_rst $c_arg$dir$c_rst already exists — entered" + echo "$c_warn""→$c_reset $c_arg$dir$c_reset already exists — entered" end end diff --git a/functions/qc.fish b/functions/qc.fish index f598ec0..87a1acf 100644 --- a/functions/qc.fish +++ b/functions/qc.fish @@ -32,26 +32,21 @@ if type -q aichat function qc --wraps aichat --description 'Quick-chat wrapper around aichat (cli role)' if contains -- -h $argv; or contains -- --help $argv - set -l c_ttl (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_flag (set_color yellow) - set -l c_txt (set_color normal) - set -l c_dim (set_color brblack) - set -l c_rst (set_color normal) + __fish_palette set -l w 59 set -l bar (string repeat -n $w ─) # Title line, padded to the box width (plain form drives the math). set -l title " qc — quick-chat: a thin aichat wrapper" set -l pad (string repeat -n (math $w - (string length -- $title)) ' ') - echo "$c_dim╭$bar╮$c_rst" - echo "$c_dim│$c_rst $c_ttl""qc$c_rst $c_dim—$c_rst quick-chat: a thin $c_cmd""aichat$c_rst wrapper$pad$c_dim│$c_rst" - echo "$c_dim╰$bar╯$c_rst" - echo " Defaults to the $c_flag'cli'$c_rst role — an AI system prompt tuned" - echo " for concise, $c_txt""terminal-friendly$c_rst output." + echo "$c_dim╭$bar╮$c_reset" + echo "$c_dim│$c_reset $c_head""qc$c_reset $c_dim—$c_reset quick-chat: a thin $c_cmd""aichat$c_reset wrapper$pad$c_dim│$c_reset" + echo "$c_dim╰$bar╯$c_reset" + echo " Defaults to the $c_flag'cli'$c_reset role — an AI system prompt tuned" + echo " for concise, $c_reset""terminal-friendly$c_reset output." echo - echo " Accepts every $c_cmd""aichat$c_rst flag; passing $c_flag--role$c_rst/$c_flag-r$c_rst overrides" - echo " the default role. $c_cmd""aichat$c_rst's own help follows:" - echo "$c_dim$bar$c_rst" + echo " Accepts every $c_cmd""aichat$c_reset flag; passing $c_flag--role$c_reset/$c_flag-r$c_reset overrides" + echo " the default role. $c_cmd""aichat$c_reset's own help follows:" + echo "$c_dim$bar$c_reset" aichat --help | string replace -a aichat qc return 0 end diff --git a/functions/rand_string.fish b/functions/rand_string.fish index c5b0312..1fcd6db 100644 --- a/functions/rand_string.fish +++ b/functions/rand_string.fish @@ -38,31 +38,27 @@ # Falls back to random choice if GNU shuf is missing, but shuf is # much faster for files with >1000 lines. function rand_string --description 'Generate random, memorable strings from curated word databases' - set -l c_head (set_color --bold cyan) - set -l c_cmd (set_color --bold) - set -l c_arg (set_color cyan) - set -l c_flag (set_color yellow) - set -l c_rst (set_color normal) + __fish_palette if set -q argv[1]; and contains -- $argv[1] -h --help - echo "$c_head""Usage:$c_rst $c_cmd""rand_string$c_rst $c_arg""[COMPONENTS/MODIFIERS]...$c_rst" + echo "$c_head""Usage:$c_reset $c_cmd""rand_string$c_reset $c_arg""[COMPONENTS/MODIFIERS]...$c_reset" echo echo " Generate random, memorable strings from curated word databases." echo - echo "$c_head""Components:$c_rst" - echo " $c_arg$c_rst A bundled word list (e.g. adjective, animal, color, name, noun, verb)" - echo " $c_arg""digits=$c_rst N random digits (e.g. digits=3 -> 842)" - echo " $c_arg""literal=$c_rst A static string component for prefixes/suffixes (e.g. literal=TEST)" + echo "$c_head""Components:$c_reset" + echo " $c_arg$c_reset A bundled word list (e.g. adjective, animal, color, name, noun, verb)" + echo " $c_arg""digits=$c_reset N random digits (e.g. digits=3 -> 842)" + echo " $c_arg""literal=$c_reset A static string component for prefixes/suffixes (e.g. literal=TEST)" echo - echo "$c_head""Modifiers:$c_rst" - echo " $c_flag-s$c_rst, $c_flag--separator=$c_rst Delimiter for subsequent words (dash, underscore, dot, none)" - echo " $c_flag-c$c_rst, $c_flag--case=$c_rst Casing for subsequent words (lower, upper, title)" - echo " $c_flag-h$c_rst, $c_flag--help$c_rst Show usage help" + echo "$c_head""Modifiers:$c_reset" + echo " $c_flag-s$c_reset, $c_flag--separator=$c_reset Delimiter for subsequent words (dash, underscore, dot, none)" + echo " $c_flag-c$c_reset, $c_flag--case=$c_reset Casing for subsequent words (lower, upper, title)" + echo " $c_flag-h$c_reset, $c_flag--help$c_reset Show usage help" echo - echo "$c_head""Examples:$c_rst" - echo " $c_cmd""rand_string$c_rst adjective animal" - echo " $c_cmd""rand_string$c_rst --case=title color animal --separator=dot digits=4" - echo " $c_cmd""rand_string$c_rst literal=TEST --separator=underscore verb noun" + echo "$c_head""Examples:$c_reset" + echo " $c_cmd""rand_string$c_reset adjective animal" + echo " $c_cmd""rand_string$c_reset --case=title color animal --separator=dot digits=4" + echo " $c_cmd""rand_string$c_reset literal=TEST --separator=underscore verb noun" return 0 end diff --git a/functions/smart_exit.fish b/functions/smart_exit.fish index 4d34c61..747b605 100644 --- a/functions/smart_exit.fish +++ b/functions/smart_exit.fish @@ -44,20 +44,16 @@ function smart_exit --description 'Capture colorized scrollback before exiting, argparse $options -- $argv or return 1 - set -l c_primary (set_color cyan) - set -l c_accent (set_color green) - set -l c_warn (set_color yellow) - set -l c_bold (set_color --bold) - set -l c_reset (set_color normal) + __fish_palette if set -q _flag_help - echo -e "Usage: $c_accent"exit"$c_reset [$c_primary""OPTIONS""$c_reset]" + echo -e "Usage: $c_accent"exit"$c_reset [$c_arg""OPTIONS""$c_reset]" echo "" echo "Closes the current shell session, automatically archiving the window scrollback." echo "" echo "Options:" - echo -e " $c_primary""-h, --help""$c_reset Show this help message" - echo -e " $c_primary""-n, --no-log""$c_reset Exit immediately $c_bold""without""$c_reset saving a scrollback history log" + echo -e " $c_arg""-h, --help""$c_reset Show this help message" + echo -e " $c_arg""-n, --no-log""$c_reset Exit immediately $c_cmd""without""$c_reset saving a scrollback history log" return 0 end @@ -112,7 +108,7 @@ function smart_exit --description 'Capture colorized scrollback before exiting, end end else - echo -e "$c_warn""➔""$c_reset Exiting discreetly; $c_bold""no history logs saved.""$c_reset" + echo -e "$c_warn""➔""$c_reset Exiting discreetly; $c_cmd""no history logs saved.""$c_reset" sleep 0.4 end