mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 09:38:16 -07:00
ca1273e7d4
* Rename `asdf which` -> `asdf current` * Output `set by $path` with current command * Use dummy plugin in current_command test * Hide "set by" message if derived from legacy file
44 lines
1.1 KiB
Bash
44 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
_asdf () {
|
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
local cmd=${COMP_WORDS[1]}
|
|
local prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
local plugins=$(asdf plugin-list | tr '\n' ' ')
|
|
|
|
COMPREPLY=()
|
|
|
|
case "$cmd" in
|
|
plugin-update)
|
|
COMPREPLY=($(compgen -W "$plugins --all" -- $cur))
|
|
;;
|
|
plugin-remove|current|list|list-all)
|
|
COMPREPLY=($(compgen -W "$plugins" -- $cur))
|
|
;;
|
|
install)
|
|
if [[ "$plugins" == *"$prev"* ]] ; then
|
|
local versions=$(asdf list-all $prev)
|
|
COMPREPLY=($(compgen -W "$versions" -- $cur))
|
|
else
|
|
COMPREPLY=($(compgen -W "$plugins" -- $cur))
|
|
fi
|
|
;;
|
|
uninstall|where|reshim)
|
|
if [[ "$plugins" == *"$prev"* ]] ; then
|
|
local versions=$(asdf list $prev)
|
|
COMPREPLY=($(compgen -W "$versions" -- $cur))
|
|
else
|
|
COMPREPLY=($(compgen -W "$plugins" -- $cur))
|
|
fi
|
|
;;
|
|
*)
|
|
local cmds='plugin-add plugin-list plugin-remove plugin-update install uninstall current where list list-all reshim'
|
|
COMPREPLY=($(compgen -W "$cmds" -- $cur))
|
|
;;
|
|
esac
|
|
|
|
return 0
|
|
}
|
|
|
|
complete -F _asdf asdf
|