#!/usr/bin/env bash proc _asdf { var cur = '' set cur = $(COMP_WORDS[COMP_CWORD]) var cmd = '' set cmd = $(COMP_WORDS[1]) var prev = '' set prev = $(COMP_WORDS[COMP_CWORD-1]) var plugins = '' set plugins = $[asdf plugin-list | tr '\n' ' ] setglobal COMPREPLY = ''() match $cmd { with plugin-update setglobal COMPREPLY = '('$(compgen -W "$plugins --all" -- "$cur")) with plugin-remove|current|list|list-all setglobal COMPREPLY = '('$(compgen -W "$plugins" -- "$cur")) with install if [[ "$plugins" == *"$prev"* ]] { var versions = '' set versions = $[asdf list-all $prev] setglobal COMPREPLY = '('$(compgen -W "$versions" -- "$cur")) } else { setglobal COMPREPLY = '('$(compgen -W "$plugins" -- "$cur")) } with uninstall|where|reshim|local|global if [[ "$plugins" == *"$prev"* ]] { var versions = '' set versions = $[asdf list $prev] setglobal COMPREPLY = '('$(compgen -W "$versions" -- "$cur")) } else { setglobal COMPREPLY = '('$(compgen -W "$plugins" -- "$cur")) } with * var cmds = ''plugin-add plugin-list plugin-remove plugin-update install uninstall update current where which list list-all local global reshim'' setglobal COMPREPLY = '('$(compgen -W "$cmds" -- "$cur")) } return 0 } complete -F _asdf asdf