Skip to content

Instantly share code, notes, and snippets.

@maple3142
Created February 12, 2025 03:31
Show Gist options
  • Save maple3142/8333a5732bb200e3a1fbad097e80c9ef to your computer and use it in GitHub Desktop.
Save maple3142/8333a5732bb200e3a1fbad097e80c9ef to your computer and use it in GitHub Desktop.
asdf shell for asdf 0.16.0+
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