Instead of offering just the base names of the packages the uninstall parameter completion now lists all installed versions. This makes it easy to uninstall whats not needed anymore and helps remembering the syntax for this task. Example: ``` $ nimble uninstall nake[TAB]@1.[TAB] nake@1.4 nake@1.6 nake@1.8 $ nimble uninstall nake@1.4 ```
43 lines
1.3 KiB
Bash
43 lines
1.3 KiB
Bash
# vim: filetype=sh
|
|
|
|
_nimble()
|
|
{
|
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
local prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
COMPREPLY=()
|
|
_init_completion || return
|
|
|
|
case "$prev" in
|
|
init|update|refresh|publish|search|build)
|
|
# no needed or available completion
|
|
;;
|
|
c|cc|js)
|
|
_filedir '@(nim)'
|
|
;;
|
|
install)
|
|
COMPREPLY=( $( nimble list 2> /dev/null | grep "^$cur" | grep -v '^ ' | tr -d ':') )
|
|
;;
|
|
path)
|
|
COMPREPLY=( $( nimble list -i 2> /dev/null | cut -d' ' -f1 | grep "^$cur" ) )
|
|
;;
|
|
uninstall)
|
|
COMPREPLY=( $( nimble list -i 2> /dev/null | awk -F'( |\\[|\\])' '{ f=4; while($f) { l=length($f); if(substr($f, l, l)==",") { $f=substr($f, 0, l-1) }; print $1 "@" $f; f++; }}' | sort -f | grep "^$cur" ) )
|
|
;;
|
|
list)
|
|
COMPREPLY=( $( compgen -W '--ver -i --installed' -- $cur ) )
|
|
;;
|
|
*)
|
|
# no $prev: suggest commands or flags
|
|
if [[ "$cur" == -* ]]; then
|
|
kw="-h -v -y -n --reject --version --accept --ver --help"
|
|
else
|
|
kw="install init publish uninstall build c cc js refresh search list path"
|
|
fi
|
|
COMPREPLY=( $( compgen -W "${kw}" -- $cur ) )
|
|
;;
|
|
esac;
|
|
|
|
return 0
|
|
}
|
|
|
|
complete -F _nimble nimble
|