From 7183ed712b88dead0b58ca21056a0a77b7d3212f Mon Sep 17 00:00:00 2001 From: rootiest Date: Mon, 27 Jul 2026 20:32:58 -0400 Subject: [PATCH] fix(config): adjust XDG and EDITOR/GPG gates and sync docs --- config.fish | 83 +++++++++++++++---------------- docs/fish-config.md | 5 +- docs/manual/07-customization.md | 3 +- docs/manual/11-troubleshooting.md | 2 +- 4 files changed, 47 insertions(+), 46 deletions(-) diff --git a/config.fish b/config.fish index c635c93..deef5fb 100644 --- a/config.fish +++ b/config.fish @@ -67,59 +67,58 @@ set --erase _fname # ───────────────────────────── XDG variables ──────────────────────────── # XDG Base Directory variables (standard practice) -# Setting XDG variables globally is opinionated (C3 overrides) -if __fish_config_op_enabled __fish_config_op_overrides - set -gx XDG_CONFIG_HOME $HOME/.config # Sets default config dir to ~/.config - set -gx XDG_CACHE_HOME $HOME/.cache # Sets default cache dir to ~/.cache - set -gx XDG_DATA_HOME $HOME/.local/share # Sets default data dir to ~/.local/share - set -gx XDG_STATE_HOME $HOME/.local/state # Sets default state dir to ~/.local/state +# We set these unconditionally to ensure a consistent baseline, but only if +# they are not already defined by the system/user. +set -q XDG_CONFIG_HOME; or set -gx XDG_CONFIG_HOME $HOME/.config # Sets default config dir to ~/.config +set -q XDG_CACHE_HOME; or set -gx XDG_CACHE_HOME $HOME/.cache # Sets default cache dir to ~/.cache +set -q XDG_DATA_HOME; or set -gx XDG_DATA_HOME $HOME/.local/share # Sets default data dir to ~/.local/share +set -q XDG_STATE_HOME; or set -gx XDG_STATE_HOME $HOME/.local/state # Sets default state dir to ~/.local/state - # Attempt to keep various config/cache files out of the home directory root - set -gx RANDFILE "$XDG_STATE_HOME/rnd" - set -gx WGETRC "$XDG_CONFIG_HOME/wget/wgetrc" - set -gx WGET_HSTS_FILE "$XDG_CACHE_HOME/wget-hsts" - set -gx NPM_CONFIG_PREFIX "$XDG_DATA_HOME/npm-global" - set -gx NPM_CONFIG_USERCONFIG "$XDG_CONFIG_HOME/npm/npmrc" - set -gx ANDROID_USER_HOME "$XDG_DATA_HOME/android" - set -gx CARGO_HOME "$XDG_DATA_HOME/cargo" - set -gx RUSTUP_HOME "$XDG_DATA_HOME/rustup" - set -gx GOPATH "$XDG_DATA_HOME/go" - set -gx BUN_INSTALL "$XDG_DATA_HOME/bun" - set -gx GNUPGHOME "$XDG_CONFIG_HOME/gnupg" - set -gx WAKATIME_HOME "$XDG_CONFIG_HOME/wakatime" - set -gx HISTFILE "$XDG_STATE_HOME/bash_history" - set -gx EXINIT "set viminfofile=$XDG_STATE_HOME/vim/viminfo | source $MYVIMRC" - set -gx NVIDIA_SETTINGS_RW_CONFIG_FILE "$XDG_CONFIG_HOME/nvidia/settings" - set -gx CODEIUM_HOME "$XDG_CONFIG_HOME/codeium" - set -gx WORDLIST "$XDG_CONFIG_HOME/hunspell_en_US" -end +# Attempt to keep various config/cache files out of the home directory root +set -q RANDFILE; or set -gx RANDFILE "$XDG_STATE_HOME/rnd" +set -q WGETRC; or set -gx WGETRC "$XDG_CONFIG_HOME/wget/wgetrc" +set -q WGET_HSTS_FILE; or set -gx WGET_HSTS_FILE "$XDG_CACHE_HOME/wget-hsts" +set -q NPM_CONFIG_PREFIX; or set -gx NPM_CONFIG_PREFIX "$XDG_DATA_HOME/npm-global" +set -q NPM_CONFIG_USERCONFIG; or set -gx NPM_CONFIG_USERCONFIG "$XDG_CONFIG_HOME/npm/npmrc" +set -q ANDROID_USER_HOME; or set -gx ANDROID_USER_HOME "$XDG_DATA_HOME/android" +set -q CARGO_HOME; or set -gx CARGO_HOME "$XDG_DATA_HOME/cargo" +set -q RUSTUP_HOME; or set -gx RUSTUP_HOME "$XDG_DATA_HOME/rustup" +set -q GOPATH; or set -gx GOPATH "$XDG_DATA_HOME/go" +set -q BUN_INSTALL; or set -gx BUN_INSTALL "$XDG_DATA_HOME/bun" +set -q GNUPGHOME; or set -gx GNUPGHOME "$XDG_CONFIG_HOME/gnupg" +set -q WAKATIME_HOME; or set -gx WAKATIME_HOME "$XDG_CONFIG_HOME/wakatime" +set -q HISTFILE; or set -gx HISTFILE "$XDG_STATE_HOME/bash_history" +set -q EXINIT; or set -gx EXINIT "set viminfofile=$XDG_STATE_HOME/vim/viminfo | source $MYVIMRC" +set -q NVIDIA_SETTINGS_RW_CONFIG_FILE; or set -gx NVIDIA_SETTINGS_RW_CONFIG_FILE "$XDG_CONFIG_HOME/nvidia/settings" +set -q CODEIUM_HOME; or set -gx CODEIUM_HOME "$XDG_CONFIG_HOME/codeium" +set -q WORDLIST; or set -gx WORDLIST "$XDG_CONFIG_HOME/hunspell_en_US" # ─────────────────────────── Pager variables ──────────────────────────── -# Overriding $PAGER is opinionated (C3 overrides) +# Overriding $PAGER, $EDITOR, and $GPG_TTY is opinionated (C3 overrides) if __fish_config_op_enabled __fish_config_op_overrides if type -q ov set -gx PAGER ov else if type -q less set -gx PAGER less end -end -# ─────────────────────────── Editor variables ─────────────────────────── -# Set Editor variables with fallback to vi if nvim isn't available. This ensures that -# tools that rely on these variables (like git commit messages) will work out of the box, -# while still preferring nvim if it's installed. -if type -q nvim - set -gx NVIM_APPNAME nvim - set -gx EDITOR (command -s nvim) -else - set -gx EDITOR (command -s vi) -end -# set -gx VISUAL $EDITOR # <- Use local.fish to set your preferred GUI editor. -set -gx SUDO_EDITOR $EDITOR + # ─────────────────────────── Editor variables ─────────────────────────── + # Set Editor variables with fallback to vi if nvim isn't available. This ensures that + # tools that rely on these variables (like git commit messages) will work out of the box, + # while still preferring nvim if it's installed. + if type -q nvim + set -gx NVIM_APPNAME nvim + set -gx EDITOR (command -s nvim) + else + set -gx EDITOR (command -s vi) + end + # set -gx VISUAL $EDITOR # <- Use local.fish to set your preferred GUI editor. + set -gx SUDO_EDITOR $EDITOR -# ──────────────────────────── GPG variables ───────────────────────────── -# Helps ensure that GPG can prompt for passphrases correctly when invoked from the terminal. -set -gx GPG_TTY (tty) + # ──────────────────────────── GPG variables ───────────────────────────── + # Helps ensure that GPG can prompt for passphrases correctly when invoked from the terminal. + set -gx GPG_TTY (tty) +end # ────────────────────────── Scrollback History ────────────────────────── # Optional fish-style source of truth (set -U via config-settings); exported diff --git a/docs/fish-config.md b/docs/fish-config.md index b3d7419..902616b 100644 --- a/docs/fish-config.md +++ b/docs/fish-config.md @@ -2857,10 +2857,11 @@ all of them. Override What it replaces or sets ─────────────────────────────────────────────────────────────────────────── Vi mode fish_vi_key_bindings replaces default Emacs mode - XDG variables Sets global XDG Base Directory variables PATH setup Prepends custom bin directories to the PATH exit → smart_exit exit wrapper that captures scrollback before closing PAGER=ov ov used by git, man, and all $PAGER-aware tools + EDITOR=nvim nvim fallback to vi for git commit, etc. + GPG_TTY Sets GPG_TTY to current terminal tty MANPAGER=bat pipeline man pages rendered with syntax highlighting CDPATH=. ~/projects ~ bare dir names resolve against ~/projects and ~ Bang-bang system ! and $ keys expand history; !^, !*, !-N, !?str?, @@ -3480,7 +3481,7 @@ what C3 controls. ## What's with the C1-C6 stuff? -This configuration groups its opinionated behaviors into six categories (C1–C6), allowing you to selectively disable features that conflict with your workflow. Disabling all of them leaves you with a "Minimal Mode" shell that only manages PATH, XDG variables, and your `local.fish` overrides. +This configuration groups its opinionated behaviors into six categories (C1–C6), allowing you to selectively disable features that conflict with your workflow. The **C**ategory numbers are used as shorthand when referencing these. Disabling all of them leaves you with a "Minimal Mode" shell that only manages basic features like `XDG` variables, and your `local.fish` overrides. Category Description ────────────────────────────────────────────────────────────────────────── diff --git a/docs/manual/07-customization.md b/docs/manual/07-customization.md index 440a6e3..ffa9222 100644 --- a/docs/manual/07-customization.md +++ b/docs/manual/07-customization.md @@ -229,10 +229,11 @@ all of them. Override What it replaces or sets ─────────────────────────────────────────────────────────────────────────── Vi mode fish_vi_key_bindings replaces default Emacs mode - XDG variables Sets global XDG Base Directory variables PATH setup Prepends custom bin directories to the PATH exit → smart_exit exit wrapper that captures scrollback before closing PAGER=ov ov used by git, man, and all $PAGER-aware tools + EDITOR=nvim nvim fallback to vi for git commit, etc. + GPG_TTY Sets GPG_TTY to current terminal tty MANPAGER=bat pipeline man pages rendered with syntax highlighting CDPATH=. ~/projects ~ bare dir names resolve against ~/projects and ~ Bang-bang system ! and $ keys expand history; !^, !*, !-N, !?str?, diff --git a/docs/manual/11-troubleshooting.md b/docs/manual/11-troubleshooting.md index 3523954..57c16a5 100644 --- a/docs/manual/11-troubleshooting.md +++ b/docs/manual/11-troubleshooting.md @@ -204,7 +204,7 @@ what C3 controls. ## What's with the C1-C6 stuff? -This configuration groups its opinionated behaviors into six categories (C1–C6), allowing you to selectively disable features that conflict with your workflow. Disabling all of them leaves you with a "Minimal Mode" shell that only manages PATH, XDG variables, and your `local.fish` overrides. +This configuration groups its opinionated behaviors into six categories (C1–C6), allowing you to selectively disable features that conflict with your workflow. The **C**ategory numbers are used as shorthand when referencing these. Disabling all of them leaves you with a "Minimal Mode" shell that only manages basic features like `XDG` variables, and your `local.fish` overrides. Category Description ──────────────────────────────────────────────────────────────────────────