Improve sudo completion (Alioth: #311414).

This commit is contained in:
Ville Skyttä 2009-09-04 23:59:34 +03:00
parent 8770727a08
commit 11d4d97887
4 changed files with 38 additions and 1 deletions

View File

@ -105,6 +105,7 @@ bash-completion (1.x)
and zmore filename completions.
* Add xz and compress support and more tarball filename extensions to
rpmbuild -t*/--tarbuild completion.
* Improve sudo completion (Alioth: #311414).
[ Todd Zullinger ]
* Make yum complete on filenames after install, deplist, update and upgrade

View File

@ -121,6 +121,7 @@ bashcomp_DATA = contrib/ant \
contrib/snownews \
contrib/ssh \
contrib/strace \
contrib/sudo \
contrib/svk \
contrib/sysctl \
contrib/sysv-rc \

View File

@ -1387,7 +1387,7 @@ _root_command()
{
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin _command $1 $2 $3
}
complete -F _root_command $filenames sudo fakeroot really gksudo gksu kdesudo
complete -F _root_command $filenames fakeroot really gksudo gksu kdesudo
_longopt()
{

35
contrib/sudo Normal file
View File

@ -0,0 +1,35 @@
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# bash completion for sudo
have sudo &&
_sudo()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
# TODO: more option completions
case $prev in
-e)
_filedir
return 0
;;
-u)
COMPREPLY=( $( compgen -u -- $cur ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-e -u' -- $cur ) )
return 0
fi
_root_command $1 $2 $3
} &&
complete -F _sudo $filenames sudo