d8bd2b32ab
Restructure and expand the Fish shell configuration for better XDG compliance, interactive-session gating, modularity, and ergonomics. config.fish: - Add full XDG Base Directory variable block (XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME, XDG_STATE_HOME) and redirect tool caches/configs accordingly (cargo, rustup, go, bun, npm, gnupg, wakatime, wget, nvidia, codeium, etc.) - Add editor setup with `type -q nvim` guard and NVIM_APPNAME - Add CDPATH block (., ~/projects, ~) with explanatory comments - Gate all interactive-only setup (key bindings, FZF, direnv, starship, secrets, local overrides, CLAUDE_CODE_NO_FLICKER) behind `status is-interactive` - Guard FZF integration source behind a file-existence check - Move secrets.fish and local.fish sourcing into the interactive block as overrides - Remove obsolete universal `cdp` variable and duplicate PATH/editor blocks - Update PATH entries to use XDG-resolved $CARGO_HOME and $BUN_INSTALL conf.d/theme.fish: - Move FZF_DEFAULT_OPTS (Catppuccin Mocha palette) from config.fish into theme.fish so all theming lives in one place - Add section header for FZF colors; condense file header comment conf.d/abbr.fish: - Add `/exit` abbreviation as a vim-style alias for the `exit` builtin conf.d/key_bindings.fish: - Bind Ctrl+Alt+= to new `qalc_eval` function (inline Qalculate! evaluation) - Add binding in both normal and all Vi modes - Add descriptive comment block explaining the keybinding purpose functions/bash.fish: - Pass `--rcfile "$XDG_CONFIG_HOME/bash/bashrc"` so bash respects XDG config location functions/cat.fish: - Extend cat wrapper: detect directory arguments and delegate to `ls` instead of bat - Preserve stdin-passthrough behavior when no arguments are provided functions/__auto_source_fallback_venv.fish (new): - Extract auto-venv PWD watcher from config.fish into its own autoloaded function file - Skips activation when direnv manages the directory (.envrc present or DIRENV_DIR set) - Deactivates venv when leaving its project tree functions/ld.fish (new): - Wrapper for lazydocker that injects the active Docker context's DOCKER_HOST, enabling correct context-aware operation functions/joplin.fish (new): - Joplin CLI wrapper function functions/qalc_eval.fish (new): - Inline Qalculate! evaluator: reads the current commandline buffer, passes it to `qalc`, prints the result, and clears the buffer for rapid-fire math in the shell README.md: - Remove stale `cdp` variable example from the local.fish documentation section Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
66 lines
4.0 KiB
Fish
66 lines
4.0 KiB
Fish
# Copyright (C) 2026 Rootiest
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
#
|
|
# ╭──────────────────────────────────────────────────────────╮
|
|
# │ Fish User Key Bindings │
|
|
# ╰──────────────────────────────────────────────────────────╯
|
|
#
|
|
# This file defines custom key bindings for the Fish shell.
|
|
# It is sourced by Fish on startup.
|
|
|
|
# ────────────────── Bind Prewious Path Head to Ctrl+G ─────────────────
|
|
# Bindings to insert the previous path head into the command line
|
|
# Behaves like `!$:h` does in bash
|
|
#
|
|
# Example: If the previous command was `cd /usr/local/bin`
|
|
# pressing Ctrl+G will insert `/usr/local` into the command line.
|
|
# ──────────────────────────────────────────────────────────────────────
|
|
|
|
# ──────────── Bind Interactive History Substitution to Ctrl+F ─────────
|
|
# Bindings to perform substitution on the previous command in the history
|
|
# Behaves like `!!:s/old/new/` does in bash
|
|
#
|
|
# Example: If the previous command was `echo this is a test`
|
|
# typing `this is/that was` and pressing Ctrl+F
|
|
# will insert `echo that was a test` into the command line.
|
|
# ──────────────────────────────────────────────────────────────────────
|
|
|
|
# ────────── Bind Replace First Command Token to Ctrl+Alt+U ────────────
|
|
# Strips the first command token and places cursor at start to retype it
|
|
#
|
|
# Example: If the current command text is `mkdir new_folder`
|
|
# pressing Ctrl+Alt+U will change the command line to ` new_folder`
|
|
# with the cursor at the start, allowing you to quickly change the command
|
|
# while keeping the arguments intact.
|
|
# To produce `cd new_folder` or `rm new_folder` etc.
|
|
# If the current command text is empty, the previous command's first token will be used instead.
|
|
# ──────────────────────────────────────────────────────────────────────
|
|
|
|
# ────────────── Bind Quick Qalc Evaluation to Ctrl+Alt+= ──────────────
|
|
# Passes the current command line buffer to the Qalculate! CLI (qalc)
|
|
#
|
|
# Example: If you type `150 * 1.08` and press Ctrl+Alt+=,
|
|
# it will print the result (162) and clear the command line.
|
|
# This allows for rapid-fire math without leaving the current shell.
|
|
# ──────────────────────────────────────────────────────────────────────
|
|
|
|
function fish_user_key_bindings
|
|
|
|
# ───────────────────────────── Set Bindings ─────────────────────────────
|
|
#
|
|
# Set Emacs mode bindings:
|
|
bind ctrl-g __insert_previous_path_head
|
|
bind ctrl-f __interactive_history_sub
|
|
bind ctrl-alt-u _replace_command_token
|
|
bind ctrl-alt-= qalc_eval
|
|
|
|
# Set bindings for all Vi modes:
|
|
# 'default' is Vi-Command, 'insert' is Vi-Insert, 'visual' is Vi-Visual
|
|
for mode in default insert visual
|
|
bind --mode $mode ctrl-g __insert_previous_path_head
|
|
bind --mode $mode ctrl-f __interactive_history_sub
|
|
bind --mode $mode ctrl-alt-u _replace_command_token
|
|
bind --mode $mode ctrl-alt-= qalc_eval
|
|
end
|
|
end
|