描述
Is your feature request related to a problem? Please describe
The current way that the asdf.fish script works is not very "fish-like":
- It is not necessary to loop over
$PATHto make sure the.asdffolders are not duplicated; we can just use the built-infish_add_pathfunction for it. - It is not necessary to always check the path on every single run, since fish already persists the path in the file
.config/fish/fish_variableswhen runningfish_add_path.- Admittedly, future changes made by the user may break asdf, but rerunning
fish_add_pathis a safe way to make sure the path is in the right order.
- Admittedly, future changes made by the user may break asdf, but rerunning
- Loading the asdf wrapper function can be done by symlinking to
.config/fish/functionsinstead, as a one-time setup step.
I recently ran into a problem where Ruby was using the system-provided bundle gem, instead of asdf; reshim did not help, and restarting the shell did not help either, as the current wrapper was not correctly prepending the folders to PATH.
Describe the proposed solution
We can replace the current script with a setup file, run only once, that modifies the path and symlinks the files.
Roughly speaking, we only need 3 lines, plus a few extra to define the right variables:
fish_add_path --move $ASDF_DIR/bin
fish_add_path --move $ASDF_DATA_DIR/shims
ln -s $ASDF_DIR/lib/asdf.fish ~/.config/fish/functions/asdf.fish
Running this once is enough, it will be persisted without modifying .config/fish/config.fish.
Future issues related to this can safely be fixed by rerunning this code.
We can replace the current wrapper with an asdf_setup.fish file, keeping the first half where we get the right variables, adding the lines above, and change fish instructions to tell users to just run the file once.
This will also keep the user's .config/fish/config.fish file clean.
Describe similar asdf features and why they are not sufficient
When using the existing fish script, the shims path was somehow put at the end of PATH, breaking my intended Ruby installation until I manually fixed it. Rerunning the script by restarting the fish changed nothing, a manual fix was needed.
Describe other workarounds you've considered
Modifying the script as said above, without the symlink, and using it as it is now (a simple wrapper) should still work.
Still, after looking at how fish handles configuration and functions, I consider it more appropriate to run this script only once instead, and let fish handle the specifics.