Skip to content

Commit 098aacf

Browse files
authored
Merge pull request #1168 from maco/fish-detect-asdf-version
fix asdf version detection in fish
2 parents 4e781b8 + f435826 commit 098aacf

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

scripts/launch.fish

+32-30
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,46 @@ test -n "$ASDF_DIR"; or set ASDF_DIR "$HOME/.asdf"
1414
# Check if we have the asdf binary for version >= 0.16.0
1515
set asdf (which asdf)
1616
if test -n "$asdf"
17-
echo "asdf executable found at $asdf. Setting ASDF_DIR=$ASDF_DIR and adding $ASDF_DATA_DIR/shims to PATH." >&2
18-
# If the binary is found, set up environment for newer asdf versions
19-
set -gx ASDF_DATA_DIR "$ASDF_DIR"
20-
set -gx PATH "$ASDF_DATA_DIR/shims" $PATH
21-
else
22-
# Fallback to old method for asdf version <= 0.15.x
23-
set ASDF_SH "$ASDF_DIR/asdf.fish"
24-
if test -f "$ASDF_SH"
17+
set asdf_version (asdf --version)
18+
set semver (string match -r '(\d+)\.(\d+)\.(\d+)' $asdf_version)
19+
if test $semver[2] -eq 0 -a $semver[3] -lt 16
20+
# Fallback to old method for asdf version <= 0.15.x
21+
set ASDF_SH "$ASDF_DIR/asdf.fish"
2522
echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing" >&2
2623
# Source the old asdf.sh script for versions <= 0.15.0
2724
source "$ASDF_SH"
2825
else
29-
echo "asdf not found" >&2
30-
echo "Looking for mise executable" >&2
26+
echo "asdf executable found at $asdf. Setting ASDF_DIR=$ASDF_DIR and adding $ASDF_DATA_DIR/shims to PATH." >&2
27+
# If the binary is found, set up environment for newer asdf versions
28+
set -gx ASDF_DATA_DIR "$ASDF_DIR"
29+
set -gx PATH "$ASDF_DATA_DIR/shims" $PATH
30+
end
31+
else
32+
echo "asdf not found" >&2
33+
echo "Looking for mise executable" >&2
34+
35+
set mise (which mise)
36+
if test -n "$mise"
37+
echo "mise executable found at $mise, activating" >&2
38+
source ( "$mise" env -s fish )
39+
else
40+
echo "mise not found" >&2
41+
echo "Looking for rtx executable" >&2
3142

32-
set mise (which mise)
33-
if test -n "$mise"
34-
echo "mise executable found at $mise, activating" >&2
35-
source ( "$mise" env -s fish )
43+
set rtx (which rtx)
44+
if test -n "$rtx"
45+
echo "rtx executable found at $rtx, activating" >&2
46+
source ( "$rtx" env -s fish )
3647
else
37-
echo "mise not found" >&2
38-
echo "Looking for rtx executable" >&2
48+
echo "rtx not found" >&2
49+
echo "Looking for vfox executable" >&2
3950

40-
set rtx (which rtx)
41-
if test -n "$rtx"
42-
echo "rtx executable found at $rtx, activating" >&2
43-
source ( "$rtx" env -s fish )
51+
set vfox (which vfox)
52+
if test -n "$vfox"
53+
echo "vfox executable found at $vfox, activating" >&2
54+
source ( "$vfox" activate fish )
4455
else
45-
echo "rtx not found" >&2
46-
echo "Looking for vfox executable" >&2
47-
48-
set vfox (which vfox)
49-
if test -n "$vfox"
50-
echo "vfox executable found at $vfox, activating" >&2
51-
source ( "$vfox" activate fish )
52-
else
53-
echo "vfox not found" >&2
54-
end
56+
echo "vfox not found" >&2
5557
end
5658
end
5759
end

0 commit comments

Comments
 (0)