feat(config): refactor config.fish, add XDG compliance, new functions, and keybindings
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>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
function __auto_source_fallback_venv --on-variable PWD
|
||||
status --is-command-substitution; and return
|
||||
|
||||
# 1. Skip if direnv is already managing this directory
|
||||
if set -q DIRENV_DIR; or test -e ".envrc"
|
||||
return
|
||||
end
|
||||
|
||||
# 2. If we are already in a venv, check if we've left its tree
|
||||
if set -q VIRTUAL_ENV
|
||||
# Check if the current PWD is still within the directory that owns the venv
|
||||
# (Assuming the venv is at the root of the project)
|
||||
set -l venv_root (string replace -r '/.venv$' '' $VIRTUAL_ENV)
|
||||
if not string match -q "$venv_root*" "$PWD"
|
||||
type -q deactivate; and deactivate
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
# 3. Only source the venv if we aren't already in one
|
||||
if test -e ".venv/bin/activate.fish"
|
||||
source .venv/bin/activate.fish
|
||||
end
|
||||
end
|
||||
+1
-1
@@ -4,6 +4,6 @@
|
||||
# bash switches to bash shell
|
||||
function bash --wraps='bash' --description 'bash switches to bash shell'
|
||||
set SHELL $(which bash) # Set shell to bash
|
||||
command bash $argv # run bash
|
||||
command bash --rcfile "$XDG_CONFIG_HOME/bash/bashrc" $argv # Run bash
|
||||
set SHELL $(which fish) # Reset shell
|
||||
end
|
||||
|
||||
+12
-2
@@ -1,8 +1,18 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# alias cat=bat
|
||||
function cat --wraps='bat' --description 'alias cat=bat'
|
||||
function cat --wraps='bat' --description 'Use bat for files and ls for directories'
|
||||
# If no arguments are provided, cat usually waits for stdin.
|
||||
# We'll maintain that behavior by skipping the directory check if $argv is empty.
|
||||
if set -q argv[1]
|
||||
if test -d $argv[1]
|
||||
# If it's a directory, run your custom ls function
|
||||
ls $argv
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
# Fallback to bat or standard cat
|
||||
if type -q bat
|
||||
bat --plain --no-pager $argv
|
||||
else
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# Run joplin CLI without Node deprecation warnings
|
||||
function joplin --description 'Run Joplin CLI without Node deprecation warnings'
|
||||
set -l joplin_path (command -v joplin)
|
||||
if test -n "$joplin_path"
|
||||
NODE_OPTIONS="--no-deprecation" $joplin_path $argv
|
||||
else
|
||||
echo "Error: joplin binary not found in PATH" >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
function ld --description 'Run lazydocker on the current Docker context'
|
||||
# Fetch the host endpoint of the currently active Docker context
|
||||
set -l current_host (docker context inspect --format '{{.Endpoints.docker.Host}}')
|
||||
|
||||
# Run lazydocker with the DOCKER_HOST variable set for this command only
|
||||
env DOCKER_HOST=$current_host lazydocker
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
function qalc_eval
|
||||
# Get the current command line buffer
|
||||
set -l cmd (commandline)
|
||||
|
||||
# If the buffer isn't empty, run it through qalc
|
||||
if test -n "$cmd"
|
||||
echo
|
||||
# Passes the buffer to qalc
|
||||
# -t (terse) is optional, remove it if you want the full verbose output
|
||||
echo "$cmd" | qalc
|
||||
|
||||
# Clear the command line for the next task
|
||||
commandline -r ""
|
||||
commandline -f repaint
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user