perf(conf.d): stop re-running expensive setup on tricks.fish's second source

tricks.fish is sourced twice per shell on CachyOS: once by the conf.d
autoload, once forced by config.fish to re-win over the distro's own
tricks.fish (measured 4.55ms for the second pass, see
startup-latency-JOB-BRIEF-FINDINGS.md §1). The bang-bang functions,
aliases, and history override further down need to re-run on both
passes since those are what re-assert over the distro config, but the
PATH/MANPAGER setup does not.

Gates fish_add_path and the type -q bat probe behind a once-per-session
global, guarding only that block. Everything else in the file, and the
coupling with config.fish's own cachyos-tricks guard, is unchanged.
This commit is contained in:
2026-09-08 01:22:10 -04:00
parent 08e66c81ca
commit f5c4016fa6
+12
View File
@@ -18,6 +18,17 @@ if test -f ~/.fish_profile
source ~/.fish_profile source ~/.fish_profile
end end
# This file is sourced twice per shell on CachyOS (once by the conf.d
# autoload, once forced by config.fish to re-win over the distro's own
# tricks.fish). The PATH/MANPAGER setup below doesn't need to repeat on
# the second pass -- only the functions/aliases further down do, since
# those are what re-assert over the distro config. Gate the expensive
# calls (fish_add_path, type -q bat) behind a once-per-session guard.
# ponytail: per-session guard, not per-value; if this file grows more
# expensive one-time setup, extend the same guard rather than adding more.
if not set -q __fish_config_tricks_env_applied
set -g __fish_config_tricks_env_applied 1
# Append unique directories to $PATH (fish_add_path handles duplicates automatically) # Append unique directories to $PATH (fish_add_path handles duplicates automatically)
fish_add_path ~/.local/bin fish_add_path ~/.local/bin
fish_add_path ~/Applications/depot_tools fish_add_path ~/Applications/depot_tools
@@ -33,6 +44,7 @@ if type -q bat; and __fish_config_op_enabled (status basename) tricks-manpager
set -gx MANROFFOPT -c set -gx MANROFFOPT -c
set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'" set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'"
end end
end
# Set settings for https://github.com/franciscolourenco/done # Set settings for https://github.com/franciscolourenco/done
set -gx __done_min_cmd_duration 10000 set -gx __done_min_cmd_duration 10000