From b3ceac52ed115f933adaf5d72cff94696abdd352 Mon Sep 17 00:00:00 2001 From: JakeBreath Date: Fri, 18 Sep 2026 13:48:02 -0500 Subject: [PATCH] fish greeting: win over distro configs that define fish_greeting inline On CachyOS (and OMF-style setups) config.fish sources a distro file that defines fish_greeting while the shell starts. A function defined that way beats autoloading from functions/, so the installed greeting never ran. install.fish now appends a guarded block to ~/.config/fish/config.fish that sources the greeting after everything else (idempotent via a marker, skipped with --no-config), and the README documents the symptom, the check (functions --details fish_greeting) and the manual one-liner. Verified in a sandbox HOME that reproduces the CachyOS setup: before the install fish resolves the distro file and prints its message, after it resolves ~/.config/fish/functions/fish_greeting.fish and runs ours; a second install leaves a single block. Applied to this machine's real config as well, where fish_greeting now resolves to the user function and the __j621_fetch_random helper is loaded. --- extras/fish_greeting/install.fish | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/extras/fish_greeting/install.fish b/extras/fish_greeting/install.fish index b6dc95a..f05f482 100755 --- a/extras/fish_greeting/install.fish +++ b/extras/fish_greeting/install.fish @@ -10,8 +10,9 @@ # fish install.fish --url https://j621.example.ts.net --token # fish install.fish --no-prompt # never ask, keep/derive defaults # fish install.fish --force # rewrite an existing config +# fish install.fish --no-config # do not touch ~/.config/fish/config.fish -argparse 'url=' 'token=' 'no-prompt' 'force' 'help' -- $argv +argparse 'url=' 'token=' 'no-prompt' 'force' 'no-config' 'help' -- $argv or begin echo "Try: fish install.fish --help" exit 1 @@ -43,6 +44,31 @@ mkdir -p $functions_dir cp "$here/fish_greeting.fish" "$functions_dir/fish_greeting.fish" echo "Installed $functions_dir/fish_greeting.fish" +# --- Override distro/OMF greetings ------------------------------------------- +# Some setups (CachyOS, OMF themes, hand-rolled configs) define fish_greeting +# inline while config.fish is being read. A function defined that way wins over +# autoloading, so our file would never load. Source it from the end of +# config.fish to define ours last. +set -l marker "# >>> J621 greeting >>>" +set -l user_config ~/.config/fish/config.fish +if set -q _flag_no_config + echo "Skipping $user_config (--no-config)" +else if test -f $user_config; and grep -qF "$marker" $user_config + echo "Config already sources the greeting (marker present)" +else + mkdir -p (dirname $user_config) + begin + echo "" + echo "$marker" + echo "# Loaded after the distro config so it wins over an inline fish_greeting." + echo "if test -f $functions_dir/fish_greeting.fish" + echo " source $functions_dir/fish_greeting.fish" + echo "end" + echo "# <<< J621 greeting <<<" + end >> $user_config + echo "Added the J621 greeting to $user_config (removes any distro greeting override)" +end + # --- Configuration ------------------------------------------------------------ mkdir -p $config_dir