diff --git a/conf.d/abbr.fish b/conf.d/abbr.fish index 02789f2..be6c762 100644 --- a/conf.d/abbr.fish +++ b/conf.d/abbr.fish @@ -76,13 +76,16 @@ abbr -a ag antigravity abbr -a ag. antigravity . # Quit abbr -a /exit exit -if test "$TERM" = xterm-kitty - abbr -a :q kitty @ close-window # Kitty (Closes the active split/pane) - abbr -a :Q kitty @ close-tab # Kitty (Closes the whole tab) -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :q wezterm cli kill-pane # WezTerm - abbr -a :Q wezterm cli kill-pane # WezTerm +# Window-management abbreviations are opinionated (C4 integrations) +if __fish_config_op_enabled __fish_config_op_integrations + if test "$TERM" = xterm-kitty + abbr -a :q kitty @ close-window # Kitty (Closes the active split/pane) + abbr -a :Q kitty @ close-tab # Kitty (Closes the whole tab) + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :q wezterm cli kill-pane # WezTerm + abbr -a :Q wezterm cli kill-pane # WezTerm + end end ######### Alternates ########## @@ -103,184 +106,188 @@ abbr -a lsT lstree # Speedtest using fast.com abbr -a speedtest-fast fast-cli -# Window Creation (OS Windows) -if test "$TERM" = xterm-kitty - abbr -a :w kitty @ launch --type=os-window # Kitty -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :w wezterm cli spawn --new-window # WezTerm -end +# 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 + # Window Creation (OS Windows) + if test "$TERM" = xterm-kitty + abbr -a :w kitty @ launch --type=os-window # Kitty + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :w wezterm cli spawn --new-window # WezTerm + end -# Window Splits (Panes) -if test "$TERM" = xterm-kitty - abbr -a :wv kitty @ launch --location=hsplit # Kitty (Horizontal split) - abbr -a :wh kitty @ launch --location=vsplit # Kitty (Vertical split) -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :wv wezterm cli split-pane --bottom # WezTerm - abbr -a :wh wezterm cli split-pane --right # WezTerm -end + # Window Splits (Panes) + if test "$TERM" = xterm-kitty + abbr -a :wv kitty @ launch --location=hsplit # Kitty (Horizontal split) + abbr -a :wh kitty @ launch --location=vsplit # Kitty (Vertical split) + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :wv wezterm cli split-pane --bottom # WezTerm + abbr -a :wh wezterm cli split-pane --right # WezTerm + end -# Window Detach (Move Pane) -if test "$TERM" = xterm-kitty - abbr -a :wo kitty @ detach-window --target-tab=new # Kitty (Moves pane to new tab) - abbr -a :wot kitty @ detach-window # Kitty (Same as above, default behavior) -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :wo wezterm cli move-pane-to-new-tab --new-window # WezTerm - abbr -a :wot wezterm cli move-pane-to-new-tab # WezTerm -end + # Window Detach (Move Pane) + if test "$TERM" = xterm-kitty + abbr -a :wo kitty @ detach-window --target-tab=new # Kitty (Moves pane to new tab) + abbr -a :wot kitty @ detach-window # Kitty (Same as above, default behavior) + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :wo wezterm cli move-pane-to-new-tab --new-window # WezTerm + abbr -a :wot wezterm cli move-pane-to-new-tab # WezTerm + end -# Tab Creation -if test "$TERM" = xterm-kitty - abbr -a :t kitty @ launch --type=tab # Kitty -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :t wezterm cli spawn # WezTerm -end + # Tab Creation + if test "$TERM" = xterm-kitty + abbr -a :t kitty @ launch --type=tab # Kitty + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :t wezterm cli spawn # WezTerm + end -# Rename Tab -if test "$TERM" = xterm-kitty - abbr -a :tl "kitty @ set-tab-title" # Kitty -> Usage: :tl "New Title" -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :tl wezterm cli set-tab-title # WezTerm -end + # Rename Tab + if test "$TERM" = xterm-kitty + abbr -a :tl "kitty @ set-tab-title" # Kitty -> Usage: :tl "New Title" + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :tl wezterm cli set-tab-title # WezTerm + end -# Rename Window -if test "$TERM" = xterm-kitty - abbr -a :tw "kitty @ set-window-title" # Kitty -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :tw wezterm cli set-window-title # WezTerm -end + # Rename Window + if test "$TERM" = xterm-kitty + abbr -a :tw "kitty @ set-window-title" # Kitty + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :tw wezterm cli set-window-title # WezTerm + end -# Rename Workspace -if test "$TERM_PROGRAM" = WezTerm - abbr -a :twk wezterm cli rename-workspace # WezTerm -end -# Kitty does not have a direct CLI equivalent for renaming a dynamic "workspace" session. + # Rename Workspace + if test "$TERM_PROGRAM" = WezTerm + abbr -a :twk wezterm cli rename-workspace # WezTerm + end + # Kitty does not have a direct CLI equivalent for renaming a dynamic "workspace" session. -# Tab Navigation -if test "$TERM" = xterm-kitty - abbr -a :tp "kitty @ focus-tab --match neighbor:left" # Kitty - abbr -a :tn "kitty @ focus-tab --match neighbor:right" # Kitty -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :tp wezterm cli activate-tab --tab-relative -1 # WezTerm - abbr -a :tn wezterm cli activate-tab --tab-relative 1 # WezTerm -end + # Tab Navigation + if test "$TERM" = xterm-kitty + abbr -a :tp "kitty @ focus-tab --match neighbor:left" # Kitty + abbr -a :tn "kitty @ focus-tab --match neighbor:right" # Kitty + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :tp wezterm cli activate-tab --tab-relative -1 # WezTerm + abbr -a :tn wezterm cli activate-tab --tab-relative 1 # WezTerm + end -# Specialty Tab Shortcuts (New Tab in specific dir) -if test "$TERM" = xterm-kitty - abbr -a :tgk kitty @ launch --type=tab --cwd ~/.config/kitty # Kitty - abbr -a :tgn kitty @ launch --type=tab --cwd ~/.config/nvim # Kitty - abbr -a :tgf kitty @ launch --type=tab --cwd ~/.config/fish # Kitty - abbr -a :tgh kitty @ launch --type=tab --cwd ~ - abbr -a :tgcz kitty @ launch --type=tab --cwd ~/.local/share/chezmoi # Kitty - abbr -a :tgcm kitty @ launch --type=tab --cwd ~/.config/chezmoi # Kitty - abbr -a :tgp kitty @ launch --type=tab --cwd ~/projects # Kitty - abbr -a :tgr kitty @ launch --type=tab -- sudo -i -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :tgk wezterm cli spawn --cwd ~/.config/kitty # WezTerm - abbr -a :tgn wezterm cli spawn --cwd ~/.config/nvim # WezTerm - abbr -a :tgf wezterm cli spawn --cwd ~/.config/fish # WezTerm - abbr -a :tgh wezterm cli spawn --cwd ~ # WezTerm - abbr -a :tgcz wezterm cli spawn --cwd ~/.local/share/chezmoi # WezTerm - abbr -a :tgcm wezterm cli spawn --cwd ~/.config/chezmoi # WezTerm - abbr -a :tgp wezterm cli spawn --cwd ~/projects # WezTerm - abbr -a :tgr wezterm cli spawn -- sudo -i # WezTerm -end + # Specialty Tab Shortcuts (New Tab in specific dir) + if test "$TERM" = xterm-kitty + abbr -a :tgk kitty @ launch --type=tab --cwd ~/.config/kitty # Kitty + abbr -a :tgn kitty @ launch --type=tab --cwd ~/.config/nvim # Kitty + abbr -a :tgf kitty @ launch --type=tab --cwd ~/.config/fish # Kitty + abbr -a :tgh kitty @ launch --type=tab --cwd ~ + abbr -a :tgcz kitty @ launch --type=tab --cwd ~/.local/share/chezmoi # Kitty + abbr -a :tgcm kitty @ launch --type=tab --cwd ~/.config/chezmoi # Kitty + abbr -a :tgp kitty @ launch --type=tab --cwd ~/projects # Kitty + abbr -a :tgr kitty @ launch --type=tab -- sudo -i + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :tgk wezterm cli spawn --cwd ~/.config/kitty # WezTerm + abbr -a :tgn wezterm cli spawn --cwd ~/.config/nvim # WezTerm + abbr -a :tgf wezterm cli spawn --cwd ~/.config/fish # WezTerm + abbr -a :tgh wezterm cli spawn --cwd ~ # WezTerm + abbr -a :tgcz wezterm cli spawn --cwd ~/.local/share/chezmoi # WezTerm + abbr -a :tgcm wezterm cli spawn --cwd ~/.config/chezmoi # WezTerm + abbr -a :tgp wezterm cli spawn --cwd ~/projects # WezTerm + abbr -a :tgr wezterm cli spawn -- sudo -i # WezTerm + end -# Specialty Window Shortcuts (New OS Window in specific dir) -if test "$TERM" = xterm-kitty - abbr -a :wgk kitty @ launch --type=os-window --cwd ~/.config/kitty # Kitty - abbr -a :wgn kitty @ launch --type=os-window --cwd ~/.config/nvim # Kitty - abbr -a :wgf kitty @ launch --type=os-window --cwd ~/.config/fish # Kitty - abbr -a :wgh kitty @ launch --type=os-window --cwd ~ - abbr -a :wgzd kitty @ launch --type=os-window --cwd ~/.local/share/chezmoi # Kitty - abbr -a :wgcz kitty @ launch --type=os-window --cwd ~/.config/chezmoi # Kitty - abbr -a :wgp kitty @ launch --type=os-window --cwd ~/projects # Kitty - abbr -a :wgr kitty @ launch --type=os-window -- sudo -i # Kitty -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :wgk wezterm cli spawn --new-window --cwd ~/.config/kitty # WezTerm - abbr -a :wgn wezterm cli spawn --new-window --cwd ~/.config/nvim # WezTerm - abbr -a :wgf wezterm cli spawn --new-window --cwd ~/.config/fish # WezTerm - abbr -a :wgh wezterm cli spawn --new-window --cwd ~ # WezTerm - abbr -a :wgzd wezterm cli spawn --new-window --cwd ~/.local/share/chezmoi # WezTerm - abbr -a :wgcz wezterm cli spawn --new-window --cwd ~/.config/chezmoi # WezTerm - abbr -a :wgp wezterm cli spawn --new-window --cwd ~/projects # WezTerm - abbr -a :wgr wezterm cli spawn --new-window -- sudo -i # WezTerm -end + # Specialty Window Shortcuts (New OS Window in specific dir) + if test "$TERM" = xterm-kitty + abbr -a :wgk kitty @ launch --type=os-window --cwd ~/.config/kitty # Kitty + abbr -a :wgn kitty @ launch --type=os-window --cwd ~/.config/nvim # Kitty + abbr -a :wgf kitty @ launch --type=os-window --cwd ~/.config/fish # Kitty + abbr -a :wgh kitty @ launch --type=os-window --cwd ~ + abbr -a :wgzd kitty @ launch --type=os-window --cwd ~/.local/share/chezmoi # Kitty + abbr -a :wgcz kitty @ launch --type=os-window --cwd ~/.config/chezmoi # Kitty + abbr -a :wgp kitty @ launch --type=os-window --cwd ~/projects # Kitty + abbr -a :wgr kitty @ launch --type=os-window -- sudo -i # Kitty + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :wgk wezterm cli spawn --new-window --cwd ~/.config/kitty # WezTerm + abbr -a :wgn wezterm cli spawn --new-window --cwd ~/.config/nvim # WezTerm + abbr -a :wgf wezterm cli spawn --new-window --cwd ~/.config/fish # WezTerm + abbr -a :wgh wezterm cli spawn --new-window --cwd ~ # WezTerm + abbr -a :wgzd wezterm cli spawn --new-window --cwd ~/.local/share/chezmoi # WezTerm + abbr -a :wgcz wezterm cli spawn --new-window --cwd ~/.config/chezmoi # WezTerm + abbr -a :wgp wezterm cli spawn --new-window --cwd ~/projects # WezTerm + abbr -a :wgr wezterm cli spawn --new-window -- sudo -i # WezTerm + end -# Specialty Window Vertical Shortcuts (Split Bottom) -if test "$TERM" = xterm-kitty - abbr -a :wvgk kitty @ launch --location=hsplit --cwd ~/.config/kitty # Kitty - abbr -a :wvgn kitty @ launch --location=hsplit --cwd ~/.config/nvim # Kitty - abbr -a :wvgf kitty @ launch --location=hsplit --cwd ~/.config/fish # Kitty - abbr -a :wvgh kitty @ launch --location=hsplit --cwd ~ # Kitty - abbr -a :wvgcz kitty @ launch --location=hsplit --cwd ~/.local/share/chezmoi # Kitty - abbr -a :wvgcm kitty @ launch --location=hsplit --cwd ~/.config/chezmoi # Kitty - abbr -a :wvgp kitty @ launch --location=hsplit --cwd ~/projects # Kitty - abbr -a :wvgr kitty @ launch --location=hsplit -- sudo -i # Kitty -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :wvgk wezterm cli split-pane --bottom --cwd ~/.config/kitty # WezTerm - abbr -a :wvgn wezterm cli split-pane --bottom --cwd ~/.config/nvim # WezTerm - abbr -a :wvgf wezterm cli split-pane --bottom --cwd ~/.config/fish # WezTerm - abbr -a :wvgh wezterm cli split-pane --bottom --cwd ~ # WezTerm - abbr -a :wvgcz wezterm cli split-pane --bottom --cwd ~/.local/share/chezmoi # WezTerm - abbr -a :wvgcm wezterm cli split-pane --bottom --cwd ~/.config/chezmoi # WezTerm - abbr -a :wvgp wezterm cli split-pane --bottom --cwd ~/projects # WezTerm - abbr -a :wvgr wezterm cli split-pane --bottom -- sudo -i # WezTerm -end + # Specialty Window Vertical Shortcuts (Split Bottom) + if test "$TERM" = xterm-kitty + abbr -a :wvgk kitty @ launch --location=hsplit --cwd ~/.config/kitty # Kitty + abbr -a :wvgn kitty @ launch --location=hsplit --cwd ~/.config/nvim # Kitty + abbr -a :wvgf kitty @ launch --location=hsplit --cwd ~/.config/fish # Kitty + abbr -a :wvgh kitty @ launch --location=hsplit --cwd ~ # Kitty + abbr -a :wvgcz kitty @ launch --location=hsplit --cwd ~/.local/share/chezmoi # Kitty + abbr -a :wvgcm kitty @ launch --location=hsplit --cwd ~/.config/chezmoi # Kitty + abbr -a :wvgp kitty @ launch --location=hsplit --cwd ~/projects # Kitty + abbr -a :wvgr kitty @ launch --location=hsplit -- sudo -i # Kitty + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :wvgk wezterm cli split-pane --bottom --cwd ~/.config/kitty # WezTerm + abbr -a :wvgn wezterm cli split-pane --bottom --cwd ~/.config/nvim # WezTerm + abbr -a :wvgf wezterm cli split-pane --bottom --cwd ~/.config/fish # WezTerm + abbr -a :wvgh wezterm cli split-pane --bottom --cwd ~ # WezTerm + abbr -a :wvgcz wezterm cli split-pane --bottom --cwd ~/.local/share/chezmoi # WezTerm + abbr -a :wvgcm wezterm cli split-pane --bottom --cwd ~/.config/chezmoi # WezTerm + abbr -a :wvgp wezterm cli split-pane --bottom --cwd ~/projects # WezTerm + abbr -a :wvgr wezterm cli split-pane --bottom -- sudo -i # WezTerm + end -# Specialty Window Horizontal Shortcuts (Split Right) -if test "$TERM" = xterm-kitty - abbr -a :whgk kitty @ launch --location=vsplit --cwd ~/.config/kitty # Kitty - abbr -a :whgn kitty @ launch --location=vsplit --cwd ~/.config/nvim # Kitty - abbr -a :whgf kitty @ launch --location=vsplit --cwd ~/.config/fish # Kitty - abbr -a :whgh kitty @ launch --location=vsplit --cwd ~ # Kitty - abbr -a :whgcz kitty @ launch --location=vsplit --cwd ~/.local/share/chezmoi # Kitty - abbr -a :whgcm kitty @ launch --location=vsplit --cwd ~/.config/chezmoi # Kitty - abbr -a :whgp kitty @ launch --location=vsplit --cwd ~/projects # Kitty - abbr -a :whgr kitty @ launch --location=vsplit --cwd current sudo -i # Kitty -> Specialty cd Shortcuts - abbr -a :cdk 'cd ~/.config/kitty/ # Kitty Config' - abbr -a :cdkn 'cd ~/.config/kitty;nvim' -end -if test "$TERM_PROGRAM" = WezTerm - abbr -a :whgk wezterm cli split-pane --bottom --cwd ~/.config/kitty # WezTerm - abbr -a :whgn wezterm cli split-pane --bottom --cwd ~/.config/nvim # WezTerm - abbr -a :whgf wezterm cli split-pane --bottom --cwd ~/.config/fish # WezTerm - abbr -a :whgh wezterm cli split-pane --bottom --cwd ~ # WezTerm - abbr -a :whgcz wezterm cli split-pane --bottom --cwd ~/.local/share/chezmoi # WezTerm - abbr -a :whgcm wezterm cli split-pane --bottom --cwd ~/.config/chezmoi # WezTerm - abbr -a :whgp wezterm cli split-pane --bottom --cwd ~/projects # WezTerm - abbr -a :whgr wezterm cli split-pane --bottom -- sudo -i # WezTerm -end -abbr -a :cdn cd '~/.config/nvim/ # Neovim Config' -abbr -a :cdnn 'cd ~/.config/nvim;nvim' -abbr -a :cdf 'cd ~/.config/fish/ # Fish Config' -abbr -a :cdfn 'cd ~/.config/fish;nvim' -abbr -a :cdh 'cd ~ # Home Directory' -abbr -a :cdhn 'cd ~;nvim' -abbr -a :cdcz cd '~/.local/share/chezmoi/ # Chezmoi Source' -abbr -a :cdczn 'cd ~/.local/share/chezmoi;nvim' -abbr -a :cdcm 'cd ~/.config/chezmoi/ # Chezmoi Config' -abbr -a :cdcmn 'cd ~/.config/chezmoi;nvim' -abbr -a :cdp --regex ':cdp' --set-cursor 'cd ~/projects/%' -# abbr -a cdp_slash --position anywhere --regex ':cdp/' --set-cursor 'cd ~/projects/%' -abbr -a :cdpn 'cd ~/projects;nvim' -abbr -a :cdw 'cd ~/.config/wezterm/ # WezTerm Config' -abbr -a :cdwn 'cd ~/.config/wezterm;nvim' -if test "$TERM" = xterm-kitty - abbr -a editt kitty @ launch --type tab nvim -end -# Spawn window -if test "$TERM" = xterm-kitty - abbr -a :sw spwin + # Specialty Window Horizontal Shortcuts (Split Right) + if test "$TERM" = xterm-kitty + abbr -a :whgk kitty @ launch --location=vsplit --cwd ~/.config/kitty # Kitty + abbr -a :whgn kitty @ launch --location=vsplit --cwd ~/.config/nvim # Kitty + abbr -a :whgf kitty @ launch --location=vsplit --cwd ~/.config/fish # Kitty + abbr -a :whgh kitty @ launch --location=vsplit --cwd ~ # Kitty + abbr -a :whgcz kitty @ launch --location=vsplit --cwd ~/.local/share/chezmoi # Kitty + abbr -a :whgcm kitty @ launch --location=vsplit --cwd ~/.config/chezmoi # Kitty + abbr -a :whgp kitty @ launch --location=vsplit --cwd ~/projects # Kitty + abbr -a :whgr kitty @ launch --location=vsplit --cwd current sudo -i # Kitty -> Specialty cd Shortcuts + abbr -a :cdk 'cd ~/.config/kitty/ # Kitty Config' + abbr -a :cdkn 'cd ~/.config/kitty;nvim' + end + if test "$TERM_PROGRAM" = WezTerm + abbr -a :whgk wezterm cli split-pane --bottom --cwd ~/.config/kitty # WezTerm + abbr -a :whgn wezterm cli split-pane --bottom --cwd ~/.config/nvim # WezTerm + abbr -a :whgf wezterm cli split-pane --bottom --cwd ~/.config/fish # WezTerm + abbr -a :whgh wezterm cli split-pane --bottom --cwd ~ # WezTerm + abbr -a :whgcz wezterm cli split-pane --bottom --cwd ~/.local/share/chezmoi # WezTerm + abbr -a :whgcm wezterm cli split-pane --bottom --cwd ~/.config/chezmoi # WezTerm + abbr -a :whgp wezterm cli split-pane --bottom --cwd ~/projects # WezTerm + abbr -a :whgr wezterm cli split-pane --bottom -- sudo -i # WezTerm + end + abbr -a :cdn cd '~/.config/nvim/ # Neovim Config' + abbr -a :cdnn 'cd ~/.config/nvim;nvim' + abbr -a :cdf 'cd ~/.config/fish/ # Fish Config' + abbr -a :cdfn 'cd ~/.config/fish;nvim' + abbr -a :cdh 'cd ~ # Home Directory' + abbr -a :cdhn 'cd ~;nvim' + abbr -a :cdcz cd '~/.local/share/chezmoi/ # Chezmoi Source' + abbr -a :cdczn 'cd ~/.local/share/chezmoi;nvim' + abbr -a :cdcm 'cd ~/.config/chezmoi/ # Chezmoi Config' + abbr -a :cdcmn 'cd ~/.config/chezmoi;nvim' + abbr -a :cdp --regex ':cdp' --set-cursor 'cd ~/projects/%' + # abbr -a cdp_slash --position anywhere --regex ':cdp/' --set-cursor 'cd ~/projects/%' + abbr -a :cdpn 'cd ~/projects;nvim' + abbr -a :cdw 'cd ~/.config/wezterm/ # WezTerm Config' + abbr -a :cdwn 'cd ~/.config/wezterm;nvim' + if test "$TERM" = xterm-kitty + abbr -a editt kitty @ launch --type tab nvim + end + # Spawn window + if test "$TERM" = xterm-kitty + abbr -a :sw spwin + end end ### Docker ### @@ -307,9 +314,13 @@ abbr -a sscs 'sudo systemctl start' abbr -a sscr 'sudo systemctl restart' ### History Expansions and Substitutions ### -abbr -a !^ --position anywhere --function expand_bang_caret -abbr -a '!*' --position anywhere --function expand_bang_all -abbr -a typo_sub --position anywhere --regex '\^([^^]+)\^([^^]*)' --function expand_typo_sub -abbr -a bang_string --position anywhere --regex '![\w.-]+' --function expand_bang_string -abbr -a bang_search --position anywhere --regex '!\?[\w.-]+\??' --function expand_bang_search -abbr -a bang_minus_n --position anywhere --regex '!-(\d+)' --function expand_bang_minus_n +# 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 + abbr -a !^ --position anywhere --function expand_bang_caret + abbr -a '!*' --position anywhere --function expand_bang_all + abbr -a typo_sub --position anywhere --regex '\^([^^]+)\^([^^]*)' --function expand_typo_sub + abbr -a bang_string --position anywhere --regex '![\w.-]+' --function expand_bang_string + abbr -a bang_search --position anywhere --regex '!\?[\w.-]+\??' --function expand_bang_search + abbr -a bang_minus_n --position anywhere --regex '!-(\d+)' --function expand_bang_minus_n +end diff --git a/conf.d/autopair.fish b/conf.d/autopair.fish index abb4bf3..571457f 100644 --- a/conf.d/autopair.fish +++ b/conf.d/autopair.fish @@ -1,5 +1,9 @@ status is-interactive || exit +# Local modification: opinionated guard (AGENTS.md Task #3). Bracket +# auto-pairing intercepts single-character input, classified as C3 overrides. +__fish_config_op_enabled __fish_config_op_overrides || exit + set --global autopair_left "(" "[" "{" '"' "'" set --global autopair_right ")" "]" "}" '"' "'" set --global autopair_pairs "()" "[]" "{}" '""' "''" diff --git a/conf.d/done.fish b/conf.d/done.fish index 9252660..bb108d0 100644 --- a/conf.d/done.fish +++ b/conf.d/done.fish @@ -24,6 +24,10 @@ if not status is-interactive exit end +# Local modification: opinionated guard (AGENTS.md Task #3). Desktop +# notifications assume a graphical session, classified as C4 integrations. +__fish_config_op_enabled __fish_config_op_integrations; or exit + set -g __done_version 1.19.1 function __done_run_powershell_script diff --git a/conf.d/first_run.fish b/conf.d/first_run.fish index ef96983..958f03a 100644 --- a/conf.d/first_run.fish +++ b/conf.d/first_run.fish @@ -29,6 +29,14 @@ echo " Run 'help config' for offline documentation." echo " Run 'fish-deps' to check and install dependencies." echo "" +# ─────────────────────── Opinionated auto-exec guard ──────────────────── +# 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 + return +end + # ──────────────────────────── Bootstrap Fisher ────────────────────────── if not type -q fisher echo " [first-run] Installing Fisher plugin manager..." diff --git a/conf.d/key_bindings.fish b/conf.d/key_bindings.fish index 109f3ca..47aa799 100644 --- a/conf.d/key_bindings.fish +++ b/conf.d/key_bindings.fish @@ -46,6 +46,10 @@ function fish_user_key_bindings + # Custom key chords are opinionated (C3 overrides); skip them entirely + # when overrides are disabled so stock bindings remain untouched. + __fish_config_op_enabled __fish_config_op_overrides; or return + # ───────────────────────────── Set Bindings ───────────────────────────── # # Set Emacs mode bindings: diff --git a/conf.d/paru-wrapper.fish b/conf.d/paru-wrapper.fish index b388062..da9db45 100644 --- a/conf.d/paru-wrapper.fish +++ b/conf.d/paru-wrapper.fish @@ -5,6 +5,10 @@ # /usr/bin/paru is installed. The wrapper tees paru output to a # timestamped log file and prunes old logs, mirroring smart_exit behavior. +# Auto-generating a wrapper in ~/.local/bin is opinionated (C2 auto-exec). +# Task #4's __fish_config_enable_logging will additionally gate this wrapper. +__fish_config_op_enabled __fish_config_op_autoexec; or return + set -l _paru_real /usr/bin/paru set -l _paru_wrapper "$HOME/.local/bin/paru" set -l _paru_wrapper_version 1 diff --git a/conf.d/puffer.fish b/conf.d/puffer.fish index 44ff6f0..a50fe03 100644 --- a/conf.d/puffer.fish +++ b/conf.d/puffer.fish @@ -1,5 +1,10 @@ status is-interactive || exit +# Local modification: opinionated guard (AGENTS.md Task #3). Puffer's key +# intercepts are part of the bang-bang system, gated atomically under C3 +# overrides with conf.d/tricks.fish, conf.d/abbr.fish, and expand_*.fish. +__fish_config_op_enabled __fish_config_op_overrides || exit + function _puffer_fish_key_bindings --on-variable fish_key_bindings set -l modes if test "$fish_key_bindings" = fish_default_key_bindings diff --git a/conf.d/starship.fish b/conf.d/starship.fish index c0c250a..a7a429a 100644 --- a/conf.d/starship.fish +++ b/conf.d/starship.fish @@ -5,6 +5,9 @@ # Without starship, fish's built-in prompt already emits OSC 133;A # on the prompt line itself, so no wrapper is needed. +# Replacing the prompt is opinionated (C3 overrides) +__fish_config_op_enabled __fish_config_op_overrides; or return + type -q starship; or return function fish_prompt diff --git a/conf.d/theme.fish b/conf.d/theme.fish index 6cc0b07..1cd1f8a 100644 --- a/conf.d/theme.fish +++ b/conf.d/theme.fish @@ -6,6 +6,16 @@ # ╰──────────────────────────────────────────────────────────╯ # Catppuccin Mocha +# Forcing theme colors and $FZF_DEFAULT_OPTS is opinionated (C3 overrides). +# The FZF variable is universal, so clean up our Catppuccin value if it +# lingers from a session where overrides were still enabled. +if not __fish_config_op_enabled __fish_config_op_overrides + if set -q FZF_DEFAULT_OPTS; and string match -q '*#1E1E2E*' -- "$FZF_DEFAULT_OPTS" + set --erase FZF_DEFAULT_OPTS + end + return +end + # ────────────────────── Syntax highlighting colors ────────────────────── set --global fish_color_autosuggestion 6c7086 set --global fish_color_cancel f38ba8 diff --git a/conf.d/tricks.fish b/conf.d/tricks.fish index 1e48268..0191b20 100644 --- a/conf.d/tricks.fish +++ b/conf.d/tricks.fish @@ -29,7 +29,8 @@ if test -f $_src; and not test -L $_man1/fish-config.1 end # Format man pages using bat (only if bat is installed) -if type -q bat +# Overriding $MANPAGER is opinionated (C3 overrides) +if type -q bat; and __fish_config_op_enabled __fish_config_op_overrides set -gx MANROFFOPT -c set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'" end @@ -40,38 +41,46 @@ set -gx __done_notification_urgency_level low ## Functions # Functions needed for !! and !$ https://github.com/oh-my-fish/plugin-bang-bang -function __history_previous_command - switch (commandline -t) - case "!" - commandline -t $history[1] - commandline -f repaint - case "*" - commandline -i ! +# 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 + function __history_previous_command + switch (commandline -t) + case "!" + commandline -t $history[1] + commandline -f repaint + case "*" + commandline -i ! + end end -end -function __history_previous_command_arguments - switch (commandline -t) - case "!" - commandline -t "" - commandline -f history-token-search-backward - case "*" - commandline -i '$' + function __history_previous_command_arguments + switch (commandline -t) + case "!" + commandline -t "" + commandline -f history-token-search-backward + case "*" + commandline -i '$' + end end -end -# Apply bang-bang key bindings based on current key binding mode -if [ "$fish_key_bindings" = fish_vi_key_bindings ] - bind -Minsert ! __history_previous_command - bind -Minsert '$' __history_previous_command_arguments -else - bind ! __history_previous_command - bind '$' __history_previous_command_arguments + # Apply bang-bang key bindings based on current key binding mode + if [ "$fish_key_bindings" = fish_vi_key_bindings ] + bind -Minsert ! __history_previous_command + bind -Minsert '$' __history_previous_command_arguments + else + bind ! __history_previous_command + bind '$' __history_previous_command_arguments + end end # Fish command history override to show timestamps -function history - builtin history --show-time='%F %T ' +# 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 + function history + builtin history --show-time='%F %T ' + end end # Quick file backup utility @@ -97,21 +106,26 @@ alias ....='cd ../../..' alias .....='cd ../../../..' alias ......='cd ../../../../..' -# Tools & Core command color overrides -alias dir='dir --color=auto' -alias vdir='vdir --color=auto' -alias grep='grep --color=auto' -alias fgrep='fgrep --color=auto' -alias egrep='egrep --color=auto' +# Silent flag injection into POSIX tools is opinionated (C1 aliasing) +if __fish_config_op_enabled __fish_config_op_aliases + # Tools & Core command color overrides + alias dir='dir --color=auto' + alias vdir='vdir --color=auto' + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' -# Safety aliases (Confirmation before overwriting/deleting) -alias cp="cp -i" -alias mv="mv -i" + # Safety aliases (Confirmation before overwriting/deleting) + alias cp="cp -i" + alias mv="mv -i" + + # Force wget to resume partial downloads + alias wget='wget -c ' +end # Archives and networking short-hands alias tarnow='tar -acf ' alias untar='tar -zxvf ' -alias wget='wget -c ' alias tb='nc termbin.com 9999' # System Logs diff --git a/conf.d/wakatime.fish b/conf.d/wakatime.fish index bedd7e0..91c88f4 100644 --- a/conf.d/wakatime.fish +++ b/conf.d/wakatime.fish @@ -5,6 +5,12 @@ # see: https://github.com/ik11235/wakatime.fish ### +# 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 + function __register_wakatime_fish_before_exec -e fish_postexec if set -q FISH_WAKATIME_DISABLED return 0 diff --git a/conf.d/yay-wrapper.fish b/conf.d/yay-wrapper.fish index d4351c9..258f1ec 100644 --- a/conf.d/yay-wrapper.fish +++ b/conf.d/yay-wrapper.fish @@ -5,6 +5,10 @@ # /usr/bin/yay is installed. The wrapper tees yay output to a # timestamped log file and prunes old logs, mirroring smart_exit behavior. +# Auto-generating a wrapper in ~/.local/bin is opinionated (C2 auto-exec). +# Task #4's __fish_config_enable_logging will additionally gate this wrapper. +__fish_config_op_enabled __fish_config_op_autoexec; or return + set -l _yay_real /usr/bin/yay set -l _yay_wrapper "$HOME/.local/bin/yay" set -l _yay_wrapper_version 1 diff --git a/conf.d/zoxide.fish b/conf.d/zoxide.fish index e6eaaf7..57a6efe 100644 --- a/conf.d/zoxide.fish +++ b/conf.d/zoxide.fish @@ -63,7 +63,11 @@ if status is-interactive # ------------- - alias cd=z + # Shadowing cd with zoxide is opinionated (C1 aliasing); z and zi + # remain available either way. + if __fish_config_op_enabled __fish_config_op_aliases + alias cd=z + end # use custom completion complete -c z -f # disable files by default diff --git a/config.fish b/config.fish index 01a9b87..07acc3c 100644 --- a/config.fish +++ b/config.fish @@ -5,17 +5,32 @@ # │ Fish Configuration │ # ╰──────────────────────────────────────────────────────────╯ +# ───────────────────── Opinionated component guards ───────────────────── +# Opinionated components (AGENTS.md Task #3) are wrapped in +# __fish_config_op_enabled guards throughout this file and conf.d/. +# The helper always evaluates the master switch __fish_config_opinionated +# first (falsy disables everything), then the per-category opt-out variable: +# __fish_config_op_aliases C1 — command shadows / flag injection +# __fish_config_op_autoexec C2 — startup side-effects +# __fish_config_op_overrides C3 — key bindings, env, prompt overrides +# __fish_config_op_integrations C4 — terminal/tool coupling +# Example: set -U __fish_config_op_aliases off (erase to re-enable) + # ──────────────────────── Source CachyOS configs ──────────────────────── if test -f /usr/share/cachyos-fish-config/cachyos-config.fish source /usr/share/cachyos-fish-config/cachyos-config.fish - # 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" - # Erase CachyOS aliases/functions that shadow our versions, then - # re-source our versions since functions --erase removes autoload entries. - for _fname in ls lt cleanup copy - functions --erase $_fname - source "$__fish_config_dir/functions/$_fname.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 + # 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" + # Erase CachyOS aliases/functions that shadow our versions, then + # re-source our versions since functions --erase removes autoload entries. + for _fname in ls lt cleanup copy + functions --erase $_fname + source "$__fish_config_dir/functions/$_fname.fish" + end end end set --erase _fname @@ -47,10 +62,13 @@ set -gx CODEIUM_HOME "$XDG_CONFIG_HOME/codeium" set -gx WORDLIST "$XDG_CONFIG_HOME/hunspell_en_US" # ─────────────────────────── Pager variables ──────────────────────────── -if type -q ov - set -gx PAGER ov -else if type -q less - set -gx PAGER less +# Overriding $PAGER 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 ─────────────────────────── @@ -76,7 +94,9 @@ set -gx SCROLLBACK_HISTORY_DIR "$HOME/.terminal_history" # Maximum number of scrollback history files to keep set -gx SCROLLBACK_HISTORY_MAX_FILES 100 # Wire up a clean exit function that won't fire on background subshells -if status is-interactive +# 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 function exit --description 'Safe interactive exit' # If the smart_exit file exists in our function path, invoke it explicitly if functions -q smart_exit @@ -112,7 +132,10 @@ fish_add_path $HOME/.fzf/bin # Fuzzy Finder (fzf) core binary an # Additionally, directories inside the CWD will still take precedence over CDPATH, # so if you have a directory named 'myproject' in the current directory, # running 'cd myproject' will take you there instead of $HOME/projects/myproject. -set -gx CDPATH . $HOME/projects $HOME +# CDPATH injection is opinionated (C3 overrides) +if __fish_config_op_enabled __fish_config_op_overrides + set -gx CDPATH . $HOME/projects $HOME +end # ──────────────────────────── Bootstrap Fisher ────────────────────────── # Fisher is bootstrapped automatically on first run via conf.d/first_run.fish @@ -123,7 +146,11 @@ if status is-interactive # ────────────────────────────── Key bindings ──────────────────────────── # Helps ensure that key bindings are consistent with the Vi editing mode set below. # This is optional but can improve the user experience for those who prefer Vi-style key bindings. - set -g fish_key_bindings fish_vi_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 + set -g fish_key_bindings fish_vi_key_bindings + end # ──────────────────────── Source FZF integration ──────────────────────── # Prefer fzf's own fish integration (fzf --fish, available since fzf 0.48) diff --git a/functions/__fish_config_op_enabled.fish b/functions/__fish_config_op_enabled.fish new file mode 100644 index 0000000..406888e --- /dev/null +++ b/functions/__fish_config_op_enabled.fish @@ -0,0 +1,46 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later + +# SYNOPSIS +# __fish_config_op_enabled +# +# DESCRIPTION +# Guard predicate for opinionated components (AGENTS.md Task #3). The master +# switch __fish_config_opinionated is always evaluated first via +# __fish_variable_check: a falsy master value (0/false/no/off/n) disables +# every category at once, regardless of the category variable's own value. +# Otherwise the supplied category variable is evaluated the same way. +# Unset or empty variables (status 2) and unrecognized values (status 3) +# leave the component enabled — opinionated components are active by +# default and these variables are pure opt-out knobs. +# +# ARGUMENTS +# category_variable Name (without $) of the category opt-out variable: +# __fish_config_op_aliases, __fish_config_op_autoexec, +# __fish_config_op_overrides, or +# __fish_config_op_integrations +# +# RETURNS +# 0 Component enabled (variables truthy, unset, or unrecognized) +# 1 Component disabled (master or category variable is falsy) +# +# EXAMPLE +# if __fish_config_op_enabled __fish_config_op_aliases +# alias grep='grep --color=auto' +# end +function __fish_config_op_enabled --description 'Check whether an opinionated component category is enabled' + # Master switch first: falsy disables all categories unconditionally. + __fish_variable_check __fish_config_opinionated + if test $status -eq 1 + return 1 + end + + # Category variable: only an explicit falsy value disables the category. + # Truthy (0), unset/empty (2), and garbage (3) all keep it enabled. + __fish_variable_check $argv[1] + if test $status -eq 1 + return 1 + end + + return 0 +end