[Bash-completion-devel] Generic rule for glib and gtk based programs

Roland Clobus rclobus at rclobus.nl
Fri Feb 26 20:38:10 UTC 2010


Hello all,

I've written a generic rule that can be used for any glib or gtk based
program. Would you like to include it in a next release?

---- cut here ---
# This function parses the output of --help-all
# All glib based programs support this command line option
#
# Only show the long options if both long and short are provided
#
_help_all()
{
	local cur opts cmd
	cur=`_get_cword`
	cmd=$1
	opts="`${cmd} --help-all | grep -- "[[:space:]]*-"| tr "," " " | awk
'$2 ~ /^--/ && $1 ~ /^-[^-]/ {print $2; next} $1 ~ /^-/ {print $1}' |
sed -e "s:=.*::g"`"
	COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
	return 0
}

--- some examples ---
complete -F _help_all $default pioneers
complete -F _help_all $default pioneers-server-console
complete -F _help_all $default pioneers-meta-server
complete -F _help_all $default pioneersai
complete -F _help_all $default pioneers-server-gtk

With kind regards,
Roland Clobus
Maintainer for Pioneers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20100226/b65bf400/attachment.pgp>


More information about the Bash-completion-devel mailing list