blob: 6fb0a96432df31860fd75a6a86813f1c09264605 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
#####
#From: ian@linuxcare.com (Ian Macdonald)
#Newsgroups: comp.unix.shell
#Subject: More bash 2.04 completions
#Date: 12 Aug 2000 09:53:40 GMT
#Organization: Linuxcare, Inc.
#Lines: 274
#Message-ID: <slrn8pa7l2.jgm.ian@lovelorn.linuxcare.com>
#Reply-To: ian@linuxcare.com
#####
# Turn on extended globbing
shopt -s extglob
# cvs(1) completion
#
_cvs ()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -eq 1 ] || [ "${prev:0:1}" = "-" ]; then
COMPREPLY=( $( compgen -W 'add admin checkout commit diff \
export history import log rdiff release remove rtag status \
tag update' $cur ))
else
COMPREPLY=( $( compgen -f $cur ))
fi
return 0
}
complete -F _cvs cvs
# rpm(8) completion. This isn't exhaustive yet, but still provides
# quite a lot of functionality.
#
_rpm()
{
dashify()
{
local i
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
if [ ${#COMPREPLY[i]} -le 2 ]; then
COMPREPLY[i]=-${COMPREPLY[i]}
else
COMPREPLY[i]=--${COMPREPLY[i]}
fi
done
}
local cur cur_nodash prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
cur_nodash=${cur#-}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD = 1 ]; then
# first parameter on line
case "$cur" in
-b*)
COMPREPLY=( $( compgen -W 'ba bb bc bi bl bp bs' \
$cur_nodash ) )
dashify
return 0
;;
-t*)
COMPREPLY=( $( compgen -W 'ta tb tc ti tl tp ts' \
$cur_nodash ) )
dashify
return 0
;;
--*)
COMPREPLY=( $( compgen -W 'help version initdb \
checksig recompile rebuild resign addsign rebuilddb \
showrc setperms setgids' ${cur_nodash#-} ) )
dashify;
return 0
;;
*)
COMPREPLY=( $( compgen -W 'b e F i q t U V' \
$cur_nodash ) )
dashify
return 0
;;
esac
fi
case "${COMP_WORDS[1]}" in
-[iFU]*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'percent force test replacepkgs \
replacefiles root excludedocs includedocs noscripts rcfile \
ignorearch dbpath prefix ignoreos nodeps allfiles ftpproxy \
ftpport justdb httpproxy httpport noorder relocate badreloc \
notriggers excludepath ignoresize oldpackage' ${cur_nodash#-} ))
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# add a list of RPMS to possible completions
COMPREPLY=( ${COMPREPLY[@]} $( compgen -G $cur\*.rpm ) )
return 0
;;
-qp*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
httpport provides triggers dump changelog dbpath filesbypkg' \
${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# add a list of RPMS to possible completions
COMPREPLY=( ${COMPREPLY[@]} $( compgen -G $cur\*.rpm ) )
return 0
;;
-*f)
# standard filename completion
COMPREPLY=( $( compgen -f $cur ) )
return 0
;;
-e)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'allmatches noscripts notriggers \
nodeps test' ${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# complete on basename of installed RPMs
COMPREPLY=( $( rpm -qa | \
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
return 0
;;
-qa*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
httpport provides triggers dump changelog dbpath specfile \
querybynumber last filesbypkg' ${cur_nodash#-} ) )
dashify;
return 0
;;
-q*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'scripts root rcfile whatprovides \
whatrequires requires triggeredby ftpport ftpproxy httpproxy \
httpport provides triggers dump changelog dbpath specfile \
querybynumber last filesbypkg' ${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# add a list of RPMS to possible completions
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
return 0
;;
-[Vy]*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'root rcfile dbpath nodeps nofiles \
noscripts nomd5 nopgp' ${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# add a list of RPMS to possible completions
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
return 0
;;
-b*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
rmsource test sign buildroot target buildarch buildos' \
${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# complete on .spec files
COMPREPLY=( $( compgen -G $cur\*.spec ) )
return 0
;;
-t*)
# complete on list of relevant options
COMPREPLY=( $( compgen -W 'short-circuit timecheck clean \
rmsource test sign buildroot target buildarch buildos' \
${cur_nodash#-} ) )
dashify;
# return if $cur is an option
[ "${cur:0:1}" = "-" ] && return 0
# complete on .tar.gz files
COMPREPLY=( $( compgen -G $cur\*.tar.gz ) )
return 0
;;
--re@(build|compile))
# complete on source RPMs
COMPREPLY=( $( compgen -G $cur\*.src.rpm ) )
return 0
;;
--@(checksig|@(re|add)sign))
# complete on RPMs
COMPREPLY=( $( compgen -G $cur\*.rpm ) )
return 0
;;
--set@(perms|gids))
# complete on installed RPMs
COMPREPLY=( ${COMPREPLY[@]} $( rpm -qa | \
sed -ne 's/^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9.]\+$/\1/p' ) )
return 0
;;
esac
}
complete -F _rpm rpm
# chsh(1) completion
#
_chsh()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ "$prev" = "-s" ]; then
COMPREPLY=( $( chsh -l | grep ^$cur ) )
else
COMPREPLY=( $( compgen -u $cur ) )
fi
}
complete -F _chsh chsh
# chkconfig(8) completion
#
_chkconfig()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
cur_nodash=${cur#--}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'list add del level' $cur_nodash ) )
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=--${COMPREPLY[i]}
done
return 0
fi
if [ $COMP_CWORD -eq 4 ]; then
COMPREPLY=( $( compgen -W 'on off reset' $cur ) )
return 0
fi
case "$prev" in
@([1-6]|--@(list|add|del)))
COMPREPLY=( $( compgen -W "`(cd /etc/rc.d/init.d; echo *)`" \
$cur) )
return 0
;;
--level)
COMPREPLY=( $( compgen -W '1 2 3 4 5 6' $cur ) )
return 0
;;
esac
}
complete -F _chkconfig chkconfig
###
|