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.
This commit is contained in:
@@ -10,8 +10,9 @@
|
|||||||
# fish install.fish --url https://j621.example.ts.net --token <api-token>
|
# fish install.fish --url https://j621.example.ts.net --token <api-token>
|
||||||
# fish install.fish --no-prompt # never ask, keep/derive defaults
|
# fish install.fish --no-prompt # never ask, keep/derive defaults
|
||||||
# fish install.fish --force # rewrite an existing config
|
# 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
|
or begin
|
||||||
echo "Try: fish install.fish --help"
|
echo "Try: fish install.fish --help"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -43,6 +44,31 @@ mkdir -p $functions_dir
|
|||||||
cp "$here/fish_greeting.fish" "$functions_dir/fish_greeting.fish"
|
cp "$here/fish_greeting.fish" "$functions_dir/fish_greeting.fish"
|
||||||
echo "Installed $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 ------------------------------------------------------------
|
# --- Configuration ------------------------------------------------------------
|
||||||
mkdir -p $config_dir
|
mkdir -p $config_dir
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user