From f5c4016fa6beb5955a0254f02cee8a2be6f2e02b Mon Sep 17 00:00:00 2001 From: Rootiest Date: Tue, 8 Sep 2026 01:22:10 -0400 Subject: [PATCH] perf(conf.d): stop re-running expensive setup on tricks.fish's second source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- conf.d/tricks.fish | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/conf.d/tricks.fish b/conf.d/tricks.fish index a3a5474..6c82fb1 100644 --- a/conf.d/tricks.fish +++ b/conf.d/tricks.fish @@ -18,20 +18,32 @@ if test -f ~/.fish_profile source ~/.fish_profile end -# Append unique directories to $PATH (fish_add_path handles duplicates automatically) -fish_add_path ~/.local/bin -fish_add_path ~/Applications/depot_tools +# 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 -# Expose user-local man pages -if not contains ~/.local/share/man $MANPATH - set -gx MANPATH ~/.local/share/man $MANPATH -end + # Append unique directories to $PATH (fish_add_path handles duplicates automatically) + fish_add_path ~/.local/bin + fish_add_path ~/Applications/depot_tools -# Format man pages using bat (only if bat is installed) -# Overriding $MANPAGER is opinionated (C3 overrides) -if type -q bat; and __fish_config_op_enabled (status basename) tricks-manpager - set -gx MANROFFOPT -c - set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'" + # Expose user-local man pages + if not contains ~/.local/share/man $MANPATH + set -gx MANPATH ~/.local/share/man $MANPATH + end + + # Format man pages using bat (only if bat is installed) + # Overriding $MANPAGER is opinionated (C3 overrides) + if type -q bat; and __fish_config_op_enabled (status basename) tricks-manpager + set -gx MANROFFOPT -c + set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'" + end end # Set settings for https://github.com/franciscolourenco/done