summaryrefslogtreecommitdiff
blob: e43b24e46710e81b808d4239df83dc13c5d62423 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  Needs a little more thought, or some method which would allow for an upstream
push without affecting the non-Gentoo users.

--- i/surfraw-bash-completion.IN
+++ w/surfraw-bash-completion.IN
@@ -4,6 +4,22 @@
 # installing the bash-completion package which sets this explicitly.
 shopt -s extglob
 
+_srpkgname()
+{
+	local pd
+	local dir=$(sed -n -e '/^PORTDIR=/ { s/^[^=]\+="\?\([^"]\+\|\S\+\).*/\1/p ; q }' \
+		/etc/make.{conf,globals})/*
+	local cur="$1"
+
+	COMPREPLY=($(compgen -W "$(
+	    for pd in $dir
+		do
+			[ ! -d ${pd} ] && continue
+			builtin cd ${pd}
+			echo *
+		done)" -- ${cur})
+	)
+}
 _surfraw() 
 {       COMPREPLY=()
 	local cur=${COMP_WORDS[COMP_CWORD]}
@@ -20,7 +36,7 @@ _surfraw()
 	then    COMPREPLY=( $( compgen -W "$elvi" -- $cur ) )
 		# "sr go<tab>" for google
 	elif    [[ $prev == @(alioth|deb@(bugs|contents|packages|pts|sec)|freshmeat|fsfdir|sourceforge) ]]
-	then    COMPREPLY=( $(apt-cache --generate pkgnames $cur) )
+	then    _srpkgname ${cur}
 		# "sr debbugs 4<tab>" to check 44bsd-rdist bugs...
 	elif    [[ -x /usr/bin/look ]] # in bsdmainutils, "important"
 	then	COMPREPLY=( $(/usr/bin/look ${cur:-''}) )