[Slapt-get-devel] BASH tab completion for slapt-get

Alec Thomas lists at swapoff.org
Sat May 22 01:27:56 EDT 2004


Hi,

This snippet of BASH performs basic tab completion of package names
in conjunction with slapt-get. If The last argument was "--remove" it
will only list packages in /var/log/packages, otherwise it will list all
packages in the repository.

<CODE>
complete_slaptget()
{
	cur=${COMP_WORDS[COMP_CWORD]}
	if [ "${COMP_WORDS[$[$COMP_CWORD-1]]}" = "--remove" ]; then
		COMPREPLY=( $( cd /var/log/packages; ls "$cur"* 2> /dev/null | sed -e 's/-[^-]*-[^-]*-[^-]*$//') )
	else
		COMPREPLY=( $( slapt-get --search "^$cur" 2> /dev/null | awk '{print $1}' ) )
	fi
}
complete -F complete_slaptget -o default slapt-get
</CODE>

eg.

[root at iris:~]slapt-get --install op<TAB><TAB>
op               openssh          openswan         
openldap         openssl          openvpn          
openldap-solibs  openssl-solibs   oprofile         
[root at iris:~]slapt-get --install op

Regards,
Alec

--
Evolution: Taking care of those too stupid to take care of themselves.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://software.jaos.org/pipermail/slapt-get-devel/attachments/20040522/22f10465/attachment.pgp


More information about the Slapt-get-devel mailing list