Created
February 12, 2025 03:31
-
-
Save maple3142/8333a5732bb200e3a1fbad097e80c9ef to your computer and use it in GitHub Desktop.
asdf shell for asdf 0.16.0+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asdf_shell() { | |
export "ASDF_${1:u}_VERSION"="$2" | |
} | |
# and completion for zsh assuming ASDF_DATA_DIR is set | |
_asdf_shell_1() { | |
local -a plugins=( "${ASDF_DATA_DIR:?}/plugins"/*(:t) ) | |
compadd -a plugins | |
} | |
_asdf_shell_2() { | |
local -a versions=( "${ASDF_DATA_DIR:?}/installs/$1"/*(:t) ) | |
versions+=system | |
compadd -a versions | |
} | |
_asdf_shell() { | |
compset -n 1 | |
_arguments '1:plugin-name:_asdf_shell_1' '2:tool-version:{_asdf_shell_2 ${words[2]}}' | |
} | |
compdef _asdf_shell asdf_shell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment