From 6b2d3bf491a8d06d642ac093b38a848ae4b4bd19 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Tue, 18 Aug 2026 02:39:47 -0400 Subject: [PATCH] refactor(config): migrate multi-category files and config.fish to named sites Adds multi-site `# COMPONENT` headers and converts every guard call site in conf.d/tricks.fish, conf.d/abbr.fish, functions/smart_exit.fish, conf.d/yay-wrapper.fish, conf.d/paru-wrapper.fish, conf.d/wakatime.fish, conf.d/first_run.fish, and config.fish (9 sites across 3 categories) to the self-identifying `(status current-function|basename) ` calling convention. Regenerates conf.d/__fish_config_op_registry.fish. --- conf.d/__fish_config_op_registry.fish | 46 +++++++++++++++++++++++++++ conf.d/abbr.fish | 10 ++++-- conf.d/first_run.fish | 8 +++-- conf.d/paru-wrapper.fish | 8 +++-- conf.d/tricks.fish | 12 ++++--- conf.d/wakatime.fish | 8 +++-- conf.d/yay-wrapper.fish | 8 +++-- config.fish | 29 +++++++++++------ functions/smart_exit.fish | 8 +++-- 9 files changed, 111 insertions(+), 26 deletions(-) diff --git a/conf.d/__fish_config_op_registry.fish b/conf.d/__fish_config_op_registry.fish index 96bda28..3691228 100644 --- a/conf.d/__fish_config_op_registry.fish +++ b/conf.d/__fish_config_op_registry.fish @@ -11,6 +11,8 @@ set -g __fish_config_op_registry_keys \ __fish_config_sync_logging: \ __fish_user_dots_link: \ _zellij_dump_log: \ + abbr:abbr-integrations \ + abbr:abbr-overrides \ agy: \ auto-pull: \ autopair: \ @@ -18,9 +20,20 @@ set -g __fish_config_op_registry_keys \ bash_expands: \ cat: \ claude: \ + config:cachyos-strip-aliases \ + config:cachyos-strip-overrides \ + config:cachyos-tricks \ + config:cdpath \ + config:exit-wiring \ + config:greeting-stamp \ + config:pager-editor-gpg \ + config:path-setup \ + config:vi-mode \ done: \ du: \ edit: \ + first_run:first-run-bootstrap \ + first_run:first-run-greeting \ fish_right_prompt: \ help: \ hist: \ @@ -32,10 +45,14 @@ set -g __fish_config_op_registry_keys \ ls: \ mkdir: \ mv: \ + paru-wrapper:paru-autoexec \ + paru-wrapper:paru-logging \ ping: \ puffer: \ rg: \ rm: \ + smart_exit:exit-plain \ + smart_exit:logging-guard \ split: \ spwin: \ ssh: \ @@ -44,7 +61,13 @@ set -g __fish_config_op_registry_keys \ theme: \ tmux-logging: \ top: \ + tricks:aliases-tricks \ + tricks:overrides-tricks \ upgrade: \ + wakatime:wakatime-autoexec \ + wakatime:wakatime-hook \ + yay-wrapper:yay-autoexec \ + yay-wrapper:yay-logging \ yt-dlp: \ zoxide: @@ -53,6 +76,8 @@ set -g __fish_config_op_registry_values \ "logging/terminal-capture" \ "autoexec/sync" \ "logging/multiplexer-capture" \ + "integrations/terminal-abbrs" \ + "overrides/key-bindings" \ "aliases/dev-tools" \ "autoexec/sync autoexec/sync" \ "overrides/key-bindings" \ @@ -60,9 +85,20 @@ set -g __fish_config_op_registry_values \ "overrides/key-bindings" \ "aliases/filesystem" \ "aliases/dev-tools" \ + "aliases/filesystem" \ + "overrides/key-bindings" \ + "aliases/filesystem" \ + "overrides/environment" \ + "overrides/key-bindings" \ + "greeting/greeting-message" \ + "overrides/environment" \ + "overrides/environment" \ + "overrides/key-bindings" \ "integrations/notifications" \ "aliases/filesystem" \ "aliases/dev-tools" \ + "autoexec/plugin-management" \ + "greeting/first-run" \ "overrides/prompt" \ "aliases/shell-tools" \ "integrations/history-logs" \ @@ -74,10 +110,14 @@ set -g __fish_config_op_registry_values \ "aliases/filesystem" \ "aliases/filesystem" \ "aliases/filesystem" \ + "autoexec/pkg-wrappers" \ + "logging/pkg-logs" \ "aliases/network" \ "overrides/key-bindings" \ "aliases/search" \ "aliases/filesystem" \ + "overrides/key-bindings" \ + "logging/terminal-capture" \ "integrations/window-mgmt" \ "integrations/window-mgmt" \ "aliases/network" \ @@ -86,7 +126,13 @@ set -g __fish_config_op_registry_values \ "overrides/prompt" \ "logging/multiplexer-capture" \ "aliases/monitor" \ + "aliases/filesystem" \ + "overrides/environment" \ "integrations/pkg-upgrade" \ + "autoexec/telemetry" \ + "integrations/notifications" \ + "autoexec/pkg-wrappers" \ + "logging/pkg-logs" \ "aliases/network" \ "aliases/filesystem" diff --git a/conf.d/abbr.fish b/conf.d/abbr.fish index f7ef839..5771e32 100644 --- a/conf.d/abbr.fish +++ b/conf.d/abbr.fish @@ -8,6 +8,10 @@ # This file contains all the abbreviations for the terminal. # It is sourced by Fish on startup. +# COMPONENT +# site abbr-integrations: integrations/terminal-abbrs +# site abbr-overrides: overrides/key-bindings + # Neovim # @category Editors # @desc nvim @@ -155,7 +159,7 @@ abbr -a ag. agy . # @desc exit abbr -a /exit exit # Window-management abbreviations are opinionated (C4 integrations) -if __fish_config_op_enabled __fish_config_op_integrations +if __fish_config_op_enabled (status basename) abbr-integrations if test "$TERM" = xterm-kitty # @category Terminal Windows, Tabs, and Panes # @desc Close current pane/window @@ -208,7 +212,7 @@ abbr -a speedtest-fast fast-cli # Kitty/WezTerm window-management abbreviations are opinionated (C4 # integrations): they assume an active Kitty or WezTerm session. -if __fish_config_op_enabled __fish_config_op_integrations +if __fish_config_op_enabled (status basename) abbr-integrations # Window Creation (OS Windows) if test "$TERM" = xterm-kitty # @category Terminal Windows, Tabs, and Panes @@ -666,7 +670,7 @@ abbr -a url-open open-url ### History Expansions and Substitutions ### # Bash-style history expansion is opinionated (C3 overrides), gated atomically # with conf.d/tricks.fish, conf.d/puffer.fish, and functions/expand_*.fish. -if __fish_config_op_enabled __fish_config_op_overrides +if __fish_config_op_enabled (status basename) abbr-overrides # @category History Expansion # @name !^ # @desc Expand to the first argument of the previous command diff --git a/conf.d/first_run.fish b/conf.d/first_run.fish index d098456..0939edf 100644 --- a/conf.d/first_run.fish +++ b/conf.d/first_run.fish @@ -7,6 +7,10 @@ # # Runs exactly once on the first interactive fish session after install. # To reset for testing, run: set -Ue __fish_config_first_run_complete +# +# COMPONENT +# site first-run-greeting: greeting/first-run +# site first-run-bootstrap: autoexec/plugin-management # Exit early in non-interactive shells (scripts, completions, subshells) if not status is-interactive @@ -36,7 +40,7 @@ end # Printing a first-run welcome banner is opinionated (C6 greeting). The # first-run state variable is already set unconditionally above, so # disabling the greeting never re-triggers this file. -if __fish_config_op_enabled __fish_config_op_greeting +if __fish_config_op_enabled (status basename) first-run-greeting echo "" echo " Welcome to your fish shell configuration!" echo " Run 'help config' for offline documentation." @@ -48,7 +52,7 @@ end # Startup side-effects below (Fisher curl, fisher update, theme apply) are # opinionated (C2 auto-execution). The first-run state variable is already # set above either way, so disabling auto-exec never re-triggers this file. -if not __fish_config_op_enabled __fish_config_op_autoexec +if not __fish_config_op_enabled (status basename) first-run-bootstrap return end diff --git a/conf.d/paru-wrapper.fish b/conf.d/paru-wrapper.fish index 13e3159..bef1e54 100644 --- a/conf.d/paru-wrapper.fish +++ b/conf.d/paru-wrapper.fish @@ -6,12 +6,16 @@ # bars are preserved, renders the captured animation to a clean static log # (via scripts/clean_progress_log.py), and prunes old logs. +# COMPONENT +# site paru-autoexec: autoexec/pkg-wrappers +# site paru-logging: logging/pkg-logs + # Auto-generating a wrapper in ~/.local/bin is opinionated (C2 auto-exec). # Wrapper generation is also gated by C5 (Logging & Capture). -__fish_config_op_enabled __fish_config_op_autoexec; or return +__fish_config_op_enabled (status basename) paru-autoexec; or return # C5 — Logging & Capture: remove generated wrapper and skip when logging is off -if not __fish_config_op_enabled __fish_config_op_logging +if not __fish_config_op_enabled (status basename) paru-logging if test -f "$HOME/.local/bin/paru" and grep -q "# paru-wrapper-version:" "$HOME/.local/bin/paru" 2>/dev/null rm -f "$HOME/.local/bin/paru" diff --git a/conf.d/tricks.fish b/conf.d/tricks.fish index 4662a49..8c1a5e5 100644 --- a/conf.d/tricks.fish +++ b/conf.d/tricks.fish @@ -7,6 +7,10 @@ # │ system aliases, and history/backup utilities │ # ╰──────────────────────────────────────────────────────────╯ +# COMPONENT +# site aliases-tricks: aliases/filesystem +# site overrides-tricks: overrides/environment + ## Environment setup # Apply .profile: use this to put fish compatible .profile stuff in if test -f ~/.fish_profile @@ -24,7 +28,7 @@ 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 __fish_config_op_overrides +if type -q bat; and __fish_config_op_enabled (status basename) overrides-tricks set -gx MANROFFOPT -c set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'" end @@ -37,7 +41,7 @@ set -gx __done_notification_urgency_level low # Functions needed for !! and !$ https://github.com/oh-my-fish/plugin-bang-bang # The bang-bang system is opinionated (C3 overrides) and is gated atomically # here, in conf.d/abbr.fish, conf.d/puffer.fish, and functions/expand_*.fish. -if __fish_config_op_enabled __fish_config_op_overrides +if __fish_config_op_enabled (status basename) overrides-tricks function __history_previous_command switch (commandline -t) case "!" @@ -83,7 +87,7 @@ end # Fish command history override to show timestamps # Shadowing the history command is opinionated (C1 aliasing); when disabled, # the function is never defined and fish's stock history behavior applies. -if __fish_config_op_enabled __fish_config_op_aliases +if __fish_config_op_enabled (status basename) aliases-tricks function history builtin history --show-time='%F %T ' end @@ -123,7 +127,7 @@ alias .....='cd ../../../..' alias ......='cd ../../../../..' # Silent flag injection into POSIX tools is opinionated (C1 aliasing) -if __fish_config_op_enabled __fish_config_op_aliases +if __fish_config_op_enabled (status basename) aliases-tricks # Tools & Core command color overrides # @category Shell Aliases # @desc dir --color=auto diff --git a/conf.d/wakatime.fish b/conf.d/wakatime.fish index 91c88f4..db97a43 100644 --- a/conf.d/wakatime.fish +++ b/conf.d/wakatime.fish @@ -5,11 +5,15 @@ # see: https://github.com/ik11235/wakatime.fish ### +# COMPONENT +# site wakatime-autoexec: autoexec/telemetry +# site wakatime-hook: integrations/notifications + # Local modification: opinionated guard (AGENTS.md Task #3). WakaTime # reporting is classified under both C2 auto-execution and C4 integrations; # disabling either category skips registering the hook. -__fish_config_op_enabled __fish_config_op_autoexec; or exit -__fish_config_op_enabled __fish_config_op_integrations; or exit +__fish_config_op_enabled (status basename) wakatime-autoexec; or exit +__fish_config_op_enabled (status basename) wakatime-hook; or exit function __register_wakatime_fish_before_exec -e fish_postexec if set -q FISH_WAKATIME_DISABLED diff --git a/conf.d/yay-wrapper.fish b/conf.d/yay-wrapper.fish index 203f306..53da589 100644 --- a/conf.d/yay-wrapper.fish +++ b/conf.d/yay-wrapper.fish @@ -6,12 +6,16 @@ # bars are preserved, renders the captured animation to a clean static log # (via scripts/clean_progress_log.py), and prunes old logs. +# COMPONENT +# site yay-autoexec: autoexec/pkg-wrappers +# site yay-logging: logging/pkg-logs + # Auto-generating a wrapper in ~/.local/bin is opinionated (C2 auto-exec). # Wrapper generation is also gated by C5 (Logging & Capture). -__fish_config_op_enabled __fish_config_op_autoexec; or return +__fish_config_op_enabled (status basename) yay-autoexec; or return # C5 — Logging & Capture: remove generated wrapper and skip when logging is off -if not __fish_config_op_enabled __fish_config_op_logging +if not __fish_config_op_enabled (status basename) yay-logging if test -f "$HOME/.local/bin/yay" and grep -q "# yay-wrapper-version:" "$HOME/.local/bin/yay" 2>/dev/null rm -f "$HOME/.local/bin/yay" diff --git a/config.fish b/config.fish index deef5fb..fe1a45b 100644 --- a/config.fish +++ b/config.fish @@ -21,12 +21,23 @@ # C5 is the one exception: it defaults to disabled and needs an explicit # truthy value — set -U __fish_config_op_logging on +# COMPONENT +# site cachyos-tricks: aliases/filesystem +# site cachyos-strip-aliases: aliases/filesystem +# site cachyos-strip-overrides: overrides/key-bindings +# site pager-editor-gpg: overrides/environment +# site exit-wiring: overrides/key-bindings +# site path-setup: overrides/environment +# site cdpath: overrides/environment +# site vi-mode: overrides/key-bindings +# site greeting-stamp: greeting/greeting-message + # ──────────────────────── Source CachyOS configs ──────────────────────── if test -f /usr/share/cachyos-fish-config/cachyos-config.fish source /usr/share/cachyos-fish-config/cachyos-config.fish # Surgically overriding the distro config is opinionated (C3 overrides): # skip it entirely when overrides are disabled, keeping CachyOS defaults. - if __fish_config_op_enabled __fish_config_op_overrides + if __fish_config_op_enabled (status basename) cachyos-tricks # Source our tricks over the cachyOS config test -f "$__fish_config_dir/conf.d/tricks.fish" and source "$__fish_config_dir/conf.d/tricks.fish" @@ -41,7 +52,7 @@ if test -f /usr/share/cachyos-fish-config/cachyos-config.fish # The distro config ships opinionated pieces of its own (it is the origin # of tricks.fish); strip them when the matching category is disabled so # the guards hold on CachyOS systems too. - if not __fish_config_op_enabled __fish_config_op_aliases + if not __fish_config_op_enabled (status basename) cachyos-strip-aliases for _fname in grep fgrep egrep dir vdir wget functions -q $_fname; and functions --erase $_fname end @@ -53,7 +64,7 @@ if test -f /usr/share/cachyos-fish-config/cachyos-config.fish and source $__fish_data_dir/functions/$_fname.fish end end - if not __fish_config_op_enabled __fish_config_op_overrides + if not __fish_config_op_enabled (status basename) cachyos-strip-overrides for _fname in __history_previous_command __history_previous_command_arguments functions -q $_fname; and functions --erase $_fname end @@ -95,7 +106,7 @@ set -q WORDLIST; or set -gx WORDLIST "$XDG_CONFIG_HOME/hunspell_en_US" # ─────────────────────────── Pager variables ──────────────────────────── # Overriding $PAGER, $EDITOR, and $GPG_TTY is opinionated (C3 overrides) -if __fish_config_op_enabled __fish_config_op_overrides +if __fish_config_op_enabled (status basename) pager-editor-gpg if type -q ov set -gx PAGER ov else if type -q less @@ -136,7 +147,7 @@ and set -gx SCROLLBACK_HISTORY_MAX_FILES $__fish_scrollback_history_max_files # Wire up a clean exit function that won't fire on background subshells # Replacing the exit builtin is opinionated (C3 overrides); smart_exit also # guards itself so a live toggle takes effect without restarting the shell. -if status is-interactive; and __fish_config_op_enabled __fish_config_op_overrides +if status is-interactive; and __fish_config_op_enabled (status basename) exit-wiring function exit --description 'Safe interactive exit' # If the smart_exit file exists in our function path, invoke it explicitly if functions -q smart_exit @@ -153,7 +164,7 @@ end # the cargo bin directory is moved to the end of the PATH, which can help avoid conflicts # with system-installed Rust tools while still allowing user-installed cargo binaries to be found. # PATH setup is opinionated (C3 overrides) -if __fish_config_op_enabled __fish_config_op_overrides +if __fish_config_op_enabled (status basename) path-setup fish_add_path $HOME/.local/bin # Standard user-local executables (XDG spec) fish_add_path $HOME/.local/share/../bin # Alternative/legacy path for local user binaries fish_add_path $HOME/Applications # User-installed applications and standalone apps @@ -176,7 +187,7 @@ end # so if you have a directory named 'myproject' in the current directory, # running 'cd myproject' will take you there instead of $HOME/projects/myproject. # CDPATH injection is opinionated (C3 overrides) -if __fish_config_op_enabled __fish_config_op_overrides +if __fish_config_op_enabled (status basename) cdpath set -gx CDPATH . $HOME/projects $HOME end @@ -191,7 +202,7 @@ if status is-interactive # This is optional but can improve the user experience for those who prefer Vi-style key bindings. # Global Vi mode is opinionated (C3 overrides); without it fish keeps its # default Emacs-style bindings. - if __fish_config_op_enabled __fish_config_op_overrides + if __fish_config_op_enabled (status basename) vi-mode set -g fish_key_bindings fish_vi_key_bindings end @@ -251,7 +262,7 @@ if status is-interactive # function that distro configs set (e.g., CachyOS defines it as fastfetch). # This runs last inside the interactive block so our empty definition wins # over whatever cachyos-config.fish or vendor conf.d installed. - if not __fish_config_op_enabled __fish_config_op_greeting + if not __fish_config_op_enabled (status basename) greeting-stamp function fish_greeting end end diff --git a/functions/smart_exit.fish b/functions/smart_exit.fish index 732103b..6b509e7 100644 --- a/functions/smart_exit.fish +++ b/functions/smart_exit.fish @@ -4,6 +4,10 @@ # CATEGORY # 11-pager-and-logging # +# COMPONENT +# site exit-plain: overrides/key-bindings +# site logging-guard: logging/terminal-capture +# # SYNOPSIS # smart_exit [-h] [-n] # @@ -32,7 +36,7 @@ function smart_exit --description 'Capture colorized scrollback before exiting, # Opinionated guard (C3): exit plainly when overrides are disabled. # This composes with Task #4's __fish_config_enable_logging, which will # gate only the scrollback capture while leaving the exit wrapper active. - if not __fish_config_op_enabled __fish_config_op_overrides + if not __fish_config_op_enabled (status current-function) exit-plain builtin exit $argv end @@ -60,7 +64,7 @@ function smart_exit --description 'Capture colorized scrollback before exiting, # C5 — Logging & Capture: skip all capture when logging is disabled. # When disabled, tell Kitty the window is handled so its watcher doesn't # capture either — belt-and-suspenders alongside the sentinel file. - if not __fish_config_op_enabled __fish_config_op_logging + if not __fish_config_op_enabled (status current-function) logging-guard if test -n "$KITTY_WINDOW_ID" kitty @ set-user-vars "logged_by_shell=true" 2>/dev/null end