2 #From: ian@linuxcare.com (Ian Macdonald)
3 #Newsgroups: comp.unix.shell
4 #Subject: More bash 2.04 completions
5 #Date: 12 Aug 2000 09:53:40 GMT
6 #Organization: Linuxcare, Inc.
8 #Message-ID: <slrn8pa7l2.jgm.ian@lovelorn.linuxcare.com>
9 #Reply-To: ian@linuxcare.com
12 # Turn on extended globbing
22 cur=${COMP_WORDS[COMP_CWORD]}
23 prev=${COMP_WORDS[COMP_CWORD-1]}
25 if [ $COMP_CWORD -eq 1 ] || [ "${prev:0:1}" = "-" ]; then
26 COMPREPLY=( $( compgen -W 'add admin checkout commit diff \
27 export history import log rdiff release remove rtag status \
30 COMPREPLY=( $( compgen -f $cur ))
36 # rpm(8) completion. This isn't exhaustive yet, but still provides
37 # quite a lot of functionality.
45 for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
46 if [ ${#COMPREPLY[i]} -le 2 ]; then
47 COMPREPLY[i]=-${COMPREPLY[i]}
49 COMPREPLY[i]=--${COMPREPLY[i]}
54 local cur cur_nodash prev
57 cur=${COMP_WORDS[COMP_CWORD]}
59 prev=${COMP_WORDS[COMP_CWORD-1]}
61 if [ $COMP_CWORD = 1 ]; then
62 # first parameter on line
65 COMPREPLY=( $( compgen -W 'ba bb bc bi bl bp bs' \
71 COMPREPLY=( $( compgen -W 'ta tb tc ti tl tp ts' \
77 COMPREPLY=( $( compgen -W 'help version initdb \
78 checksig recompile rebuild resign addsign rebuilddb \
79 showrc setperms setgids' ${cur_nodash#-} ) )
84 COMPREPLY=( $( compgen -W 'b e F i q t U V' \
92 case "${COMP_WORDS[1]}" in
94 # complete on list of relevant options
95 COMPREPLY=( $( compgen -W 'percent force test replacepkgs \
96 replacefiles root excludedocs includedocs noscripts rcfile \
97 ignorearch dbpath prefix ignoreos nodeps allfiles ftpproxy \
98 ftpport justdb httpproxy httpport noorder relocate badreloc \
99 notriggers excludepath ignoresize oldpackage' ${cur_nodash#-} ))
101 # return if $cur is an option
102 [ "${cur:0:1}" = "-" ] && return 0
103 # add a list of RPMS to possible completions
104 COMPREPLY=( ${COMPREPLY[@]} $( compgen -G $cur\*.rpm ) )
108 # complete on list of relevant options
109 COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
110 whatrequires requires triggeredby ftpport ftpproxy httpproxy \
111 httpport provides triggers dump changelog dbpath filesbypkg' \
114 # return if $cur is an option
115 [ "${cur:0:1}" = "-" ] && return 0
116 # add a list of RPMS to possible completions
117 COMPREPLY=( ${COMPREPLY[@]} $( compgen -G $cur\*.rpm ) )
121 # standard filename completion
122 COMPREPLY=( $( compgen -f $cur ) )
126 # complete on list of relevant options
127 COMPREPLY=( $( compgen -W 'allmatches noscripts notriggers \
128 nodeps test' ${cur_nodash#-} ) )
130 # return if $cur is an option
131 [ "${cur:0:1}" = "-" ] && return 0
132 # complete on basename of installed RPMs
133 COMPREPLY=( $( rpm -qa | \
134 sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
138 # complete on list of relevant options
139 COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
140 whatrequires requires triggeredby ftpport ftpproxy httpproxy \
141 httpport provides triggers dump changelog dbpath specfile \
142 querybynumber last filesbypkg' ${cur_nodash#-} ) )
147 # complete on list of relevant options
148 COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
149 whatrequires requires triggeredby ftpport ftpproxy httpproxy \
150 httpport provides triggers dump changelog dbpath specfile \
151 querybynumber last filesbypkg' ${cur_nodash#-} ) )
153 # return if $cur is an option
154 [ "${cur:0:1}" = "-" ] && return 0
155 # add a list of RPMS to possible completions
156 COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
157 sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
161 # complete on list of relevant options
162 COMPREPLY=( $( compgen -W 'root rcfile dbpath nodeps nofiles \
163 noscripts nomd5 nopgp' ${cur_nodash#-} ) )
165 # return if $cur is an option
166 [ "${cur:0:1}" = "-" ] && return 0
167 # add a list of RPMS to possible completions
168 COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
169 sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
173 # complete on list of relevant options
174 COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
175 rmsource test sign buildroot target buildarch buildos' \
178 # return if $cur is an option
179 [ "${cur:0:1}" = "-" ] && return 0
180 # complete on .spec files
181 COMPREPLY=( $( compgen -G $cur\*.spec ) )
185 # complete on list of relevant options
186 COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
187 rmsource test sign buildroot target buildarch buildos' \
190 # return if $cur is an option
191 [ "${cur:0:1}" = "-" ] && return 0
192 # complete on .tar.gz files
193 COMPREPLY=( $( compgen -G $cur\*.tar.gz ) )
196 --re@(build|compile))
197 # complete on source RPMs
198 COMPREPLY=( $( compgen -G $cur\*.src.rpm ) )
201 --@(checksig|@(re|add)sign))
203 COMPREPLY=( $( compgen -G $cur\*.rpm ) )
207 # complete on installed RPMs
208 COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
209 sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
223 cur=${COMP_WORDS[COMP_CWORD]}
224 prev=${COMP_WORDS[COMP_CWORD-1]}
226 if [ "$prev" = "-s" ]; then
227 COMPREPLY=( $( chsh -l | grep ^$cur ) )
229 COMPREPLY=( $( compgen -u $cur ) )
232 complete -F _chsh chsh
234 # chkconfig(8) completion
241 cur=${COMP_WORDS[COMP_CWORD]}
243 prev=${COMP_WORDS[COMP_CWORD-1]}
245 if [ $COMP_CWORD -eq 1 ]; then
246 COMPREPLY=( $( compgen -W 'list add del level' $cur_nodash ) )
247 for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
248 COMPREPLY[i]=--${COMPREPLY[i]}
253 if [ $COMP_CWORD -eq 4 ]; then
254 COMPREPLY=( $( compgen -W 'on off reset' $cur ) )
259 @([1-6]|--@(list|add|del)))
260 COMPREPLY=( $( compgen -W "`(cd /etc/rc.d/init.d; echo *)`" \
265 COMPREPLY=( $( compgen -W '1 2 3 4 5 6' $cur ) )
270 complete -F _chkconfig chkconfig