[Slapt-get-user] Re: [Slapt-get-devel] BASH tab completion for slapt-get

Jason Woodward slapt-get-user@software.jaos.org
Mon, 24 May 2004 16:09:54 -0400


--boundary-1085424025
Content-Type: text/plain; charset="us-ascii"
Content-Length: 962
Lines: 43

Hi Alec,

thanks... thats definately going into my bashrc file.


take care,
jason





> 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@iris:~]slapt-get --install op<TAB><TAB>
op               openssh          openswan         
openldap         openssl          openvpn          
openldap-solibs  openssl-solibs   oprofile         




--boundary-1085424025--