From 4bdc06ffbae4e418c63248d2d1be19b717fa8380 Mon Sep 17 00:00:00 2001 From: Ty Smith Date: Tue, 21 Jul 2026 18:12:21 -0700 Subject: [PATCH] fish: switch mise from shims to PATH activation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shims are only generated at `mise reshim` time, so anything added to a tool's bin dir afterward (`cargo install`, `npm i -g`) was invisible until a manual reshim — cargo-audit et al. silently missing from PATH. Plain `mise activate` runs `mise hook-env` from a fish_prompt hook, putting the real bin dirs (incl. ~/.cargo/bin) on PATH, so new binaries appear immediately. hook-env respects entries added after activation, so ~/.local/share/overrides/bin keeps first position (verified across startup, repeated prompts, and version-switching cd). __cached_source now keys the cache on tool + subcommand, not just tool: the old mise.fish cache (shims line) would otherwise keep winning after this change, since args weren't part of the cache key. Old-scheme cache files are cleaned on cold start. Co-Authored-By: Claude Fable 5 --- dot_config/fish/conf.d/zz_01_paths.fish.tmpl | 6 +++++- dot_config/fish/conf.d/zz_03_interactive.fish | 11 ++++++----- dot_config/fish/functions/__auto_venv.fish | 6 +++--- dot_config/fish/functions/__cached_source.fish | 10 ++++++---- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dot_config/fish/conf.d/zz_01_paths.fish.tmpl b/dot_config/fish/conf.d/zz_01_paths.fish.tmpl index 536a75c..f50fbad 100644 --- a/dot_config/fish/conf.d/zz_01_paths.fish.tmpl +++ b/dot_config/fish/conf.d/zz_01_paths.fish.tmpl @@ -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 diff --git a/dot_config/fish/conf.d/zz_03_interactive.fish b/dot_config/fish/conf.d/zz_03_interactive.fish index 2b8b0fd..03d5d7b 100644 --- a/dot_config/fish/conf.d/zz_03_interactive.fish +++ b/dot_config/fish/conf.d/zz_03_interactive.fish @@ -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 diff --git a/dot_config/fish/functions/__auto_venv.fish b/dot_config/fish/functions/__auto_venv.fish index 3173aec..92533f0 100644 --- a/dot_config/fish/functions/__auto_venv.fish +++ b/dot_config/fish/functions/__auto_venv.fish @@ -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). # diff --git a/dot_config/fish/functions/__cached_source.fish b/dot_config/fish/functions/__cached_source.fish index 6249e2c..dfb3a66 100644 --- a/dot_config/fish/functions/__cached_source.fish +++ b/dot_config/fish/functions/__cached_source.fish @@ -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/.fish + # Caches output to ~/.cache/fish/-.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" @@ -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 (.fish, ..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