mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
fix: support asdf shim-versions
completions in fish & bash (#1554)
authored-by: Yuri Pieters <yuri.pieters@anaplan.com>
This commit is contained in:
parent
d8ce35357f
commit
99623d7eac
@ -1,3 +1,12 @@
|
||||
_asdf_list_shims() (
|
||||
# this function runs in a subshell so shopt is scoped
|
||||
shopt -s nullglob # globs that don't match should disappear
|
||||
shopt -u failglob # globs that don't match shouldn't fail
|
||||
for shim in "${ASDF_DATA_DIR:-$HOME/.asdf}"/shims/*; do
|
||||
basename "$shim"
|
||||
done
|
||||
)
|
||||
|
||||
_asdf() {
|
||||
local cur
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
@ -71,13 +80,13 @@ _asdf() {
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "--all" -- "$cur"))
|
||||
;;
|
||||
which)
|
||||
which | shim-versions)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -c -- "$cur"))
|
||||
COMPREPLY=($(compgen -W "$(_asdf_list_shims)" -- "$cur"))
|
||||
;;
|
||||
plugin-list | plugin-list-all | info) ;;
|
||||
*)
|
||||
local cmds='current global help install latest list list-all local plugin-add plugin-list plugin-list-all plugin-remove plugin-update reshim shell uninstall update where which info'
|
||||
local cmds='current global help install latest list list-all local plugin-add plugin-list plugin-list-all plugin-remove plugin-update reshim shim-versions shell uninstall update where which info'
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
|
||||
;;
|
||||
|
@ -47,7 +47,7 @@ function __fish_asdf_plugin_list_all
|
||||
end
|
||||
|
||||
function __fish_asdf_list_shims
|
||||
ls $asdf_data_dir/shims
|
||||
path basename $asdf_data_dir/shims/*
|
||||
end
|
||||
|
||||
# update
|
||||
@ -116,6 +116,10 @@ complete -f -c asdf -n __fish_asdf_needs_command -a reshim -d "Recreate shims fo
|
||||
complete -f -c asdf -n '__fish_asdf_using_command reshim; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
||||
complete -f -c asdf -n '__fish_asdf_using_command reshim; and __fish_asdf_arg_number 3' -a '(__fish_asdf_list_versions (__fish_asdf_arg_at 3))'
|
||||
|
||||
# shim-versions completion
|
||||
complete -f -c asdf -n __fish_asdf_needs_command -a shim-versions -d "List the plugins and versions that provide a command"
|
||||
complete -f -c asdf -n '__fish_asdf_using_command shim-versions; and __fish_asdf_arg_number 2' -a '(__fish_asdf_list_shims)'
|
||||
|
||||
# local completion
|
||||
complete -f -c asdf -n __fish_asdf_needs_command -a local -d "Set local version for a plugin"
|
||||
complete -f -c asdf -n '__fish_asdf_using_command local; and __fish_asdf_arg_number 2' -a '(__fish_asdf_plugin_list)'
|
||||
|
Loading…
Reference in New Issue
Block a user