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

Jason Woodward woodwardj at jaos.org
Mon May 24 16:09:54 EDT 2004


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





More information about the Slapt-get-devel mailing list