Add update-alternatives --set, --usage, and --slave completions, simplify some bits.
This commit is contained in:
parent
d68c8e508a
commit
09045a63b6
3
CHANGES
3
CHANGES
@ -24,7 +24,8 @@ bash-completion (2.x)
|
|||||||
* Apply pine completion to alpine too.
|
* Apply pine completion to alpine too.
|
||||||
* Remove many unnecessary short option completions where long ones exist.
|
* Remove many unnecessary short option completions where long ones exist.
|
||||||
* Improve configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
|
* Improve configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
|
||||||
mysqladmin, screen, service, scp, ssh, and general hostname completions.
|
mysqladmin, screen, service, scp, ssh, update-alternatives, and general
|
||||||
|
hostname completions.
|
||||||
* Add abook and wtf completion, based on work by Raphaël Droz.
|
* Add abook and wtf completion, based on work by Raphaël Droz.
|
||||||
* Add jarsigner, k3b, lftpget, pack200 and unpack200 completions.
|
* Add jarsigner, k3b, lftpget, pack200 and unpack200 completions.
|
||||||
* Don't overwrite other host completions when completing from multiple
|
* Don't overwrite other host completions when completing from multiple
|
||||||
|
@ -30,14 +30,14 @@ _update_alternatives()
|
|||||||
_filedir -d
|
_filedir -d
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--help|--version)
|
--help|--usage|--version)
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# find which mode to use and how many real args used so far
|
# find which mode to use and how many real args used so far
|
||||||
for (( i=1; i < COMP_CWORD; i++ )); do
|
for (( i=1; i < COMP_CWORD; i++ )); do
|
||||||
if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all) ]]; then
|
if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all|set) ]]; then
|
||||||
mode=${COMP_WORDS[i]}
|
mode=${COMP_WORDS[i]}
|
||||||
args=$(($COMP_CWORD - i))
|
args=$(($COMP_CWORD - i))
|
||||||
break
|
break
|
||||||
@ -47,18 +47,30 @@ _update_alternatives()
|
|||||||
case $mode in
|
case $mode in
|
||||||
--install)
|
--install)
|
||||||
case $args in
|
case $args in
|
||||||
1)
|
1|3)
|
||||||
_filedir
|
_filedir
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
_installed_alternatives
|
_installed_alternatives
|
||||||
;;
|
;;
|
||||||
3)
|
4)
|
||||||
|
# priority - no completions
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
case $((args % 4)) in
|
||||||
|
0|2)
|
||||||
_filedir
|
_filedir
|
||||||
;;
|
;;
|
||||||
|
1)
|
||||||
|
COMPREPLY=( $( compgen -W '--slave' -- "$cur" ) )
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
_installed_alternatives
|
||||||
|
;;
|
||||||
|
esac
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
--remove)
|
--remove|--set)
|
||||||
case $args in
|
case $args in
|
||||||
1)
|
1)
|
||||||
_installed_alternatives
|
_installed_alternatives
|
||||||
@ -68,23 +80,13 @@ _update_alternatives()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
--auto)
|
--auto|--remove-all|--display|--config)
|
||||||
_installed_alternatives
|
|
||||||
;;
|
|
||||||
--remove-all)
|
|
||||||
_installed_alternatives
|
|
||||||
;;
|
|
||||||
--display)
|
|
||||||
_installed_alternatives
|
|
||||||
;;
|
|
||||||
--config)
|
|
||||||
_installed_alternatives
|
_installed_alternatives
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \
|
COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \
|
||||||
--altdir --admindir' -- "$cur" ) \
|
--altdir --admindir --install --remove --auto --display \
|
||||||
$( compgen -W '--install --remove --auto --display \
|
--config --set' -- "$cur" ) )
|
||||||
--config' -- "$cur" ) )
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
complete -F _update_alternatives update-alternatives alternatives
|
complete -F _update_alternatives update-alternatives alternatives
|
||||||
|
Loading…
x
Reference in New Issue
Block a user