public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Bash completion for emerge
@ 2001-12-12 19:32 Geert Bevin
  2001-12-13 13:17 ` Mikael Hallendal
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Bevin @ 2001-12-12 19:32 UTC (permalink / raw
  To: gentoo-dev

[-- 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] Bash completion for emerge
  2001-12-12 19:32 [gentoo-dev] Bash completion for emerge Geert Bevin
@ 2001-12-13 13:17 ` Mikael Hallendal
  2001-12-13 17:08   ` Zach Forrest
  2001-12-13 18:19   ` Daniel Robbins
  0 siblings, 2 replies; 6+ messages in thread
From: Mikael Hallendal @ 2001-12-13 13:17 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 521 bytes --]

ons 2001-12-12 klockan 20.32 skrev Geert Bevin:
> 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.

Imho, we should add this to the default bash-installation? 
What do you think?

Regards,
  Mikael Hallendal

-- 

Mikael Hallendal
Gentoo Linux Developer, Desktop Team Leader
CodeFactory AB, Stockholm, Sweden


[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] Bash completion for emerge
  2001-12-13 13:17 ` Mikael Hallendal
@ 2001-12-13 17:08   ` Zach Forrest
  2001-12-13 19:03     ` Geert Bevin
  2001-12-13 18:19   ` Daniel Robbins
  1 sibling, 1 reply; 6+ messages in thread
From: Zach Forrest @ 2001-12-13 17:08 UTC (permalink / raw
  To: gentoo-dev

One of the earlier versions I wrote actually did this. It's on the 
ebuild mailing list. It also contains a patch for bash that offers some 
functionality for service completion on /etc/init.d. Just let me know 
what you would like. I'm at your disposal.

Zach

Mikael Hallendal wrote:

> ons 2001-12-12 klockan 20.32 skrev Geert Bevin:
> 
>>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.
>>
> 
> Imho, we should add this to the default bash-installation? 
> What do you think?
> 
> Regards,
>   Mikael Hallendal
> 
> 




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] Bash completion for emerge
  2001-12-13 13:17 ` Mikael Hallendal
  2001-12-13 17:08   ` Zach Forrest
@ 2001-12-13 18:19   ` Daniel Robbins
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Robbins @ 2001-12-13 18:19 UTC (permalink / raw
  To: gentoo-dev

On Thu, Dec 13, 2001 at 02:17:32PM +0100, Mikael Hallendal wrote:

> Imho, we should add this to the default bash-installation? 
> What do you think?

Let's hold off for a little bit.  Maybe in a week or so.

-- 
Daniel Robbins                                  <drobbins@gentoo.org>
Chief Architect/President                       http://www.gentoo.org 
Gentoo Technologies, Inc.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] Bash completion for emerge
  2001-12-13 17:08   ` Zach Forrest
@ 2001-12-13 19:03     ` Geert Bevin
  2001-12-13 21:22       ` Zach Forrest
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Bevin @ 2001-12-13 19:03 UTC (permalink / raw
  To: gentoo-dev

On Thu, 2001-12-13 at 18:08, Zach Forrest wrote:
> One of the earlier versions I wrote actually did this. It's on the 
> ebuild mailing list. It also contains a patch for bash that offers some 
> functionality for service completion on /etc/init.d. Just let me know 
> what you would like. I'm at your disposal.
> 
> Zach

Hmmm ... your bash_completion post contains completions for emerge and
ebuild? I must be looking over it 'cause I can't find it. I'd like to
see how you implemented it, would be good see which version performs
best.

-- 
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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] Bash completion for emerge
  2001-12-13 19:03     ` Geert Bevin
@ 2001-12-13 21:22       ` Zach Forrest
  0 siblings, 0 replies; 6+ messages in thread
From: Zach Forrest @ 2001-12-13 21:22 UTC (permalink / raw
  To: gentoo-dev

Sorry, I think I misunderstood what you had said. I meant that I had 
originally modified the bash package to install bash_completion at the 
same time.

Geert Bevin wrote:

> On Thu, 2001-12-13 at 18:08, Zach Forrest wrote:
> 
>>One of the earlier versions I wrote actually did this. It's on the 
>>ebuild mailing list. It also contains a patch for bash that offers some 
>>functionality for service completion on /etc/init.d. Just let me know 
>>what you would like. I'm at your disposal.
>>
>>Zach
>>
> 
> Hmmm ... your bash_completion post contains completions for emerge and
> ebuild? I must be looking over it 'cause I can't find it. I'd like to
> see how you implemented it, would be good see which version performs
> best.
> 
> 




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-12-13 21:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-12 19:32 [gentoo-dev] Bash completion for emerge Geert Bevin
2001-12-13 13:17 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox