[Yum-devel] [PATCH] Add bash completion.

James Antill james at fedoraproject.org
Fri Oct 23 15:21:02 UTC 2009


On Fri, 2009-10-23 at 14:26 +0300, Ville Skyttä wrote:
> +
> +# arguments:
> +#   1 = argument to "yum list" (all, available, updates etc)
> +#   2 = current word to be completed
> +_yum_list()
> +{
> +    if [ "$1" = all ] ; then
> +        # Try to strip in between headings like "Available Packages"
> - would
> +        # be nice if e.g. -d 0 did that for us.  This will obviously
> only work
> +        # for English :P
> +        COMPREPLY=( "${COMPREPLY[@]}"
> +            $( ${yum:-yum} -d 0 -C list $1 "$2*" 2>/dev/null | \
> +                sed -ne '/^\(Available\|Installed\|Updated\) /d' \
> +                -e 's/[[:space:]].*//p' ) )
> +    else
> +        # Drop first line (e.g. "Updated Packages") - would be nice
> if e.g.
> +        # -d 0 did that for us.
> +        COMPREPLY=( "${COMPREPLY[@]}"
> +            $( ${yum:-yum} -d 0 -C list $1 "$2*" 2>/dev/null | \
> +                sed -ne 1d -e 's/[[:space:]].*//p' ) )
> +    fi
> +}

 This is just matching on name, yeh? ... so it can't match things like
"yum-*.25", right? And what does it do with the overflow lines¹?
 Esp. given the sed hack, is it not easier to drop some yum API scripts
into /usr/libexec/yum-bash-completion ... or something?


¹ Eg. displaying the wonderful packages like:

php-pear-Structures-DataGrid-DataSource-DataObject-0.2.1-2.fc11.noarch
kmod-open-vm-tools-2.6.29.6-217.2.16.fc11.x86_64-0.0.0.179896-1.fc11.5.x86_64 



More information about the Yum-devel mailing list