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