From: Geert Bevin <gbevin@theleaf.be>
To: gentoo-dev@gentoo.org
Subject: [gentoo-dev] Bash completion for emerge
Date: 12 Dec 2001 20:32:18 +0100 [thread overview]
Message-ID: <1008185542.23324.2.camel@willow.theleaf.office> (raw)
[-- Attachment #1: Type: text/plain, Size: 527 bytes --]
Hi all,
as a diversion I amused myself by trying out the bash programmable
completion. I currently have it working for emerge. I'm not a bash
expert and surely this code can be written in a much better way, but it
already works.
To use it, just add the atachment to /etc/bash_completion.
Hope this is of some help to someone,
Geert
--
Geert Bevin
the Leaf sprl/bvba
"Use what you need" Pierre Theunisstraat 1/47
http://www.theleaf.be 1030 Brussels
gbevin@theleaf.be Tel & Fax +32 2 241 19 98
[-- Attachment #2: emerge.completion --]
[-- Type: text/plain, Size: 1053 bytes --]
# Gentoo emerge completion.
#
_emerge()
{
local cur prev grepcmd sedcmd setsma setbig
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -lt 2 ]; then
cd /usr/portage
grepcmd="grep -E ^$cur.*"
sedcmd="sed -e /CVS/d \
-e /BUGS-TODO/d \
-e /ChangeLog.*/d \
-e /header.txt/d \
-e /skel.build/d \
-e /distfiles/d \
-e /eclass/d \
-e /files/d \
-e /incoming/d \
-e /packages/d \
-e /profiles/d \
-e /scripts/d"
setsma=`compgen -S '/' -G "*" | $sedcmd`
setbig=`compgen -G "*/*" | $sedcmd`
if [ $cur ]; then
if [ `echo $cur | grep '/'` ]; then
COMPREPLY=( $( echo "$setbig" | $grepcmd ) )
else
if [ `echo "$setsma" | $grepcmd | grep '/' | wc -l` = 1 ]; then
COMPREPLY=( $( echo "$setbig" | $grepcmd ) )
else
COMPREPLY=( $( echo "$setsma" | $grepcmd ) )
fi
fi
else
COMPREPLY=( $( echo "$setsma" ) )
fi
fi
return 0
}
complete -F _emerge emerge
next reply other threads:[~2001-12-12 19:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-12 19:32 Geert Bevin [this message]
2001-12-13 13:17 ` [gentoo-dev] Bash completion for emerge Mikael Hallendal
2001-12-13 17:08 ` Zach Forrest
2001-12-13 19:03 ` Geert Bevin
2001-12-13 21:22 ` Zach Forrest
2001-12-13 18:19 ` Daniel Robbins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1008185542.23324.2.camel@willow.theleaf.office \
--to=gbevin@theleaf.be \
--cc=gentoo-dev@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox