Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dot_config/fish/conf.d/zz_01_paths.fish.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ fish_add_path -a --path $OMARCHY_PATH/bin
{{ end -}}

# Mise - polyglot runtime version manager (Java, Python, Node, etc.)
__cached_source mise activate --shims fish
# PATH activation (not --shims): a fish_prompt hook runs `mise hook-env`, which
# puts the real tool bin dirs (incl. ~/.cargo/bin) on PATH — so binaries added
# by `cargo install` / `npm i -g` work without a `mise reshim`. hook-env keeps
# entries added after activation (like the overrides move below) in front.
__cached_source mise activate fish

# Custom bins
fish_add_path -a --path ~/.local/bin
Expand Down
11 changes: 6 additions & 5 deletions dot_config/fish/conf.d/zz_03_interactive.fish
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ if status is-interactive
end
end

# Auto-activate Python virtualenvs on `cd` (any repo with a .venv). Required
# because we use mise --shims, which don't run the cd hook that mise's
# python.uv_venv_auto relies on. The function autoloads from
# ~/.config/fish/functions/__auto_venv.fish; calling it here loads the file
# (registering its --on-variable PWD handler) and activates the start dir.
# Auto-activate Python virtualenvs on `cd` (any repo with a .venv). mise's
# python.uv_venv_auto only covers projects with mise-managed python, which
# is intentionally not a global tool — this owns plain-.venv repos. The
# function autoloads from ~/.config/fish/functions/__auto_venv.fish; calling
# it here loads the file (registering its --on-variable PWD handler) and
# activates the start dir.
__auto_venv
end
6 changes: 3 additions & 3 deletions dot_config/fish/functions/__auto_venv.fish
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function __auto_venv --on-variable PWD --description 'Auto-activate the nearest Python .venv on cd'
# Auto-activate Python virtualenvs on `cd` for any repo that has a .venv —
# including uv projects: mise's python.uv_venv_auto only fires through the
# `mise activate` HOOK, which we don't run (we use --shims), so this function
# owns ALL interactive venv activation. Activates the nearest ancestor .venv,
# including uv projects: mise's python.uv_venv_auto only covers projects with
# mise-managed python (intentionally not a global tool), so this function
# owns plain-.venv activation. Activates the nearest ancestor .venv,
# deactivates on leaving its tree, and never touches a venv we didn't activate
# (manual / mise) — we only ever deactivate the one we started (__auto_venv_dir).
#
Expand Down
10 changes: 6 additions & 4 deletions dot_config/fish/functions/__cached_source.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ function __cached_source --description 'Source a command output with stale-while
# Example: __cached_source zoxide init fish
# Example: __cached_source /home/linuxbrew/.linuxbrew/bin/brew shellenv
#
# Caches output to ~/.cache/fish/<name>.fish
# Caches output to ~/.cache/fish/<tool>-<subcmds>.fish — the subcommand is
# part of the cache key, so changing args (e.g. dropping a flag) invalidates.
# On cache hit: sources immediately (zero validation cost — all builtins)
# If tool binary is newer than cache: regenerates in background for next startup
# Accepts full paths — uses basename for the cache filename.

set -l tool $argv[1]
set -l subcmd $argv[2..-1]
set -l name (string replace -r '.*/' '' $tool)
set -l name (string join '-' (string replace -r '.*/' '' $tool) $subcmd | string replace -a '/' '-')

set -l tool_path (command -s $tool 2>/dev/null)
if test -z "$tool_path"
Expand All @@ -31,8 +32,9 @@ function __cached_source --description 'Source a command output with stale-while
else
# Cold start: generate synchronously
mkdir -p $cache_dir
# Clean up old versioned cache files (previous naming scheme)
for old in $cache_dir/$name.*.fish
# Clean up cache files from previous naming schemes (<tool>.fish, <tool>.<ver>.fish)
set -l base (string replace -r '.*/' '' $tool)
for old in $cache_dir/$base.fish $cache_dir/$base.*.fish
command rm -f $old
end
$tool $subcmd >$cache_file
Expand Down
Loading