]> git.ipfire.org Git - thirdparty/bash.git/blob - examples/complete/bash_completion
commit bash-20080821 snapshot
[thirdparty/bash.git] / examples / complete / bash_completion
1 # bash_completion - programmable completion functions for bash 3.x
2 # (backwards compatible with bash 2.05b)
3 #
4 # $Id: bash_completion,v 1.872 2006/03/01 16:20:18 ianmacd Exp $
5 #
6 # Copyright (C) Ian Macdonald <ian@caliban.org>
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software Foundation,
20 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #
22 # The latest version of this software can be obtained here:
23 #
24 # http://www.caliban.org/bash/index.shtml#completion
25 #
26 # RELEASE: 20060301
27
28 if [[ $- == *v* ]]; then
29 BASH_COMPLETION_ORIGINAL_V_VALUE="-v"
30 else
31 BASH_COMPLETION_ORIGINAL_V_VALUE="+v"
32 fi
33
34 if [[ -n $BASH_COMPLETION_DEBUG ]]; then
35 set -v
36 else
37 set +v
38 fi
39
40 # Alter the following to reflect the location of this file.
41 #
42 [ -n "$BASH_COMPLETION" ] || BASH_COMPLETION=/etc/bash_completion
43 [ -n "$BASH_COMPLETION_DIR" ] || BASH_COMPLETION_DIR=/etc/bash_completion.d
44 readonly BASH_COMPLETION BASH_COMPLETION_DIR
45
46 # Set a couple of useful vars
47 #
48 UNAME=$( uname -s )
49 # strip OS type and version under Cygwin (e.g. CYGWIN_NT-5.1 => Cygwin)
50 UNAME=${UNAME/CYGWIN_*/Cygwin}
51 RELEASE=$( uname -r )
52
53 # features supported by bash 2.05 and higher
54 if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} > 04 ]] ||
55 [ ${BASH_VERSINFO[0]} -gt 2 ]; then
56 declare -r bash205=$BASH_VERSION 2>/dev/null || :
57 default="-o default"
58 dirnames="-o dirnames"
59 filenames="-o filenames"
60 fi
61 # features supported by bash 2.05b and higher
62 if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] ||
63 [ ${BASH_VERSINFO[0]} -gt 2 ]; then
64 declare -r bash205b=$BASH_VERSION 2>/dev/null || :
65 nospace="-o nospace"
66 fi
67 # features supported by bash 3.0 and higher
68 if [ ${BASH_VERSINFO[0]} -gt 2 ]; then
69 declare -r bash3=$BASH_VERSION 2>/dev/null || :
70 bashdefault="-o bashdefault"
71 plusdirs="-o plusdirs"
72 fi
73
74 # Turn on extended globbing and programmable completion
75 shopt -s extglob progcomp
76
77 # A lot of the following one-liners were taken directly from the
78 # completion examples provided with the bash 2.04 source distribution
79
80 # Make directory commands see only directories
81 complete -d pushd
82
83 # The following section lists completions that are redefined later
84 # Do NOT break these over multiple lines.
85 #
86 # START exclude -- do NOT remove this line
87 complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat bzcmp bzdiff bzegrep bzfgrep bzgrep
88 complete -f -X '!*.@(zip|ZIP|jar|JAR|exe|EXE|pk3|war|wsz|ear|zargo|xpi|sxw|ott)' unzip zipinfo
89 complete -f -X '*.Z' compress znew
90 complete -f -X '!*.@(Z|gz|tgz|Gz|dz)' gunzip zcmp zdiff zcat zegrep zfgrep zgrep zless zmore
91 complete -f -X '!*.Z' uncompress
92 complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' ee display
93 complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|GIF|JPG|JP?(E)G|TIF?(F)|PNG|P[BGP]M|BMP|X[BP]M|RLE|RGB|PCX|FITS|PM)' xv qiv
94 complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview
95 complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi
96 complete -f -X '!*.@(dvi|DVI)?(.@(gz|bz2))' kdvi
97 complete -f -X '!*.@(dvi|DVI)' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx
98 complete -f -X '!*.@(pdf|PDF)' acroread gpdf xpdf
99 complete -f -X '!*.@(?(e)ps|?(E)PS|pdf|PDF)' kpdf
100 complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ)|cb(r|z)|CB(R|Z)|djv?(u)|DJV?(U)||dvi|DVI|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX)' evince
101 complete -f -X '!*.@(?(e)ps|?(E)PS)' ps2pdf
102 complete -f -X '!*.texi*' makeinfo texi2html
103 complete -f -X '!*.@(?(la)tex|?(LA)TEX|texi|TEXI|dtx|DTX|ins|INS)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
104 complete -f -X '!*.@(mp3|MP3)' mpg123 mpg321 madplay
105 complete -f -X '!*.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp3|MP3|m4v|M4V|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV|asx|ASX|mng|MNG|srt)' xine aaxine fbxine kaffeine
106 complete -f -X '!*.@(avi|asf|wmv)' aviplay
107 complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay
108 complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim
109 complete -f -X '!*.@(ogg|OGG|m3u|flac|spx)' ogg123
110 complete -f -X '!*.@(mp3|MP3|ogg|OGG|pls|m3u)' gqmpeg freeamp
111 complete -f -X '!*.fig' xfig
112 complete -f -X '!*.@(mid?(i)|MID?(I))' playmidi
113 complete -f -X '!*.@(mid?(i)|MID?(I)|rmi|RMI|rcp|RCP|[gr]36|[GR]36|g18|G18|mod|MOD|xm|XM|it|IT|x3m|X3M)' timidity
114 complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' vi vim gvim rvim view rview rgvim rgview gview
115 complete -f -X '*.@(o|so|so.!(conf)|a|rpm|gif|GIF|jp?(e)g|JP?(E)G|mp3|MP3|mp?(e)g|MPG|avi|AVI|asf|ASF|ogg|OGG|class|CLASS)' emacs
116 complete -f -X '!*.@(exe|EXE|com|COM|scr|SCR|exe.so)' wine
117 complete -f -X '!*.@(zip|ZIP|z|Z|gz|GZ|tgz|TGZ)' bzme
118 complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon curl dillo elinks amaya
119 complete -f -X '!*.@(sxw|stw|sxg|sgl|doc|dot|rtf|txt|htm|html|odt|ott|odm)' oowriter
120 complete -f -X '!*.@(sxi|sti|pps|ppt|pot|odp|otp)' ooimpress
121 complete -f -X '!*.@(sxc|stc|xls|xlw|xlt|csv|ods|ots)' oocalc
122 complete -f -X '!*.@(sxd|std|sda|sdd|odg|otg)' oodraw
123 complete -f -X '!*.@(sxm|smf|mml|odf)' oomath
124 complete -f -X '!*.odb' oobase
125 complete -f -X '!*.rpm' rpm2cpio
126 # FINISH exclude -- do not remove this line
127
128 # start of section containing compspecs that can be handled within bash
129
130 # user commands see only users
131 complete -u su usermod userdel passwd chage write chfn groups slay w sux
132
133 # group commands see only groups
134 [ -n "$bash205" ] && complete -g groupmod groupdel newgrp 2>/dev/null
135
136 # bg completes with stopped jobs
137 complete -A stopped -P '%' bg
138
139 # other job commands
140 complete -j -P '%' fg jobs disown
141
142 # readonly and unset complete with shell variables
143 complete -v readonly unset
144
145 # set completes with set options
146 complete -A setopt set
147
148 # shopt completes with shopt options
149 complete -A shopt shopt
150
151 # helptopics
152 complete -A helptopic help
153
154 # unalias completes with aliases
155 complete -a unalias
156
157 # bind completes with readline bindings (make this more intelligent)
158 complete -A binding bind
159
160 # type and which complete on commands
161 complete -c command type which
162
163 # builtin completes on builtins
164 complete -b builtin
165
166 # start of section containing completion functions called by other functions
167
168 # This function checks whether we have a given program on the system.
169 # No need for bulky functions in memory if we don't.
170 #
171 have()
172 {
173 unset -v have
174 PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null &&
175 have="yes"
176 }
177
178 # use GNU sed if we have it, since its extensions are still used in our code
179 #
180 [ $UNAME != Linux ] && have gsed && alias sed=gsed
181
182 # This function checks whether a given readline variable
183 # is `on'.
184 #
185 _rl_enabled()
186 {
187 [[ "$( bind -v )" = *$1+([[:space:]])on* ]]
188 }
189
190 # This function shell-quotes the argument
191 quote()
192 {
193 echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
194 }
195
196 # This function quotes the argument in a way so that readline dequoting
197 # results in the original argument
198 quote_readline()
199 {
200 local t="${1//\\/\\\\}"
201 echo \'${t//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
202 }
203
204 # This function shell-dequotes the argument
205 dequote()
206 {
207 eval echo "$1"
208 }
209
210
211 # Get the word to complete
212 # This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases
213 # where the user is completing in the middle of a word.
214 # (For example, if the line is "ls foobar",
215 # and the cursor is here --------> ^
216 # it will complete just "foo", not "foobar", which is what the user wants.)
217 _get_cword()
218 {
219 if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
220 echo "${COMP_WORDS[COMP_CWORD]}"
221 else
222 local i
223 local cur="$COMP_LINE"
224 local index="$COMP_POINT"
225 for (( i = 0; i <= COMP_CWORD; ++i )); do
226 while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
227 cur="${cur:1}"
228 index="$(( index - 1 ))"
229 done
230 if [[ "$i" -lt "$COMP_CWORD" ]]; then
231 local old_size="${#cur}"
232 cur="${cur#${COMP_WORDS[i]}}"
233 local new_size="${#cur}"
234 index="$(( index - old_size + new_size ))"
235 fi
236 done
237
238 if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
239 # We messed up! At least return the whole word so things keep working
240 echo "${COMP_WORDS[COMP_CWORD]}"
241 else
242 echo "${cur:0:$index}"
243 fi
244 fi
245 }
246
247
248 # This function performs file and directory completion. It's better than
249 # simply using 'compgen -f', because it honours spaces in filenames.
250 # If passed -d, it completes only on directories. If passed anything else,
251 # it's assumed to be a file glob to complete on.
252 #
253 _filedir()
254 {
255 local IFS=$'\t\n' xspec
256
257 _expand || return 0
258
259 local toks=( ) tmp
260 while read -r tmp; do
261 [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
262 done < <( compgen -d -- "$(quote_readline "$cur")" )
263
264 if [[ "$1" != -d ]]; then
265 xspec=${1:+"!*.$1"}
266 while read -r tmp; do
267 [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
268 done < <( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" )
269 fi
270
271 COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
272 }
273
274 # This function completes on signal names
275 #
276 _signals()
277 {
278 local i
279
280 # standard signal completion is rather braindead, so we need
281 # to hack around to get what we want here, which is to
282 # complete on a dash, followed by the signal name minus
283 # the SIG prefix
284 COMPREPLY=( $( compgen -A signal SIG${cur#-} ))
285 for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
286 COMPREPLY[i]=-${COMPREPLY[i]#SIG}
287 done
288 }
289
290 # This function completes on configured network interfaces
291 #
292 _configured_interfaces()
293 {
294 if [ -f /etc/debian_version ]; then
295 # Debian system
296 COMPREPLY=( $( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' \
297 /etc/network/interfaces ) )
298 elif [ -f /etc/SuSE-release ]; then
299 # SuSE system
300 COMPREPLY=( $( command ls \
301 /etc/sysconfig/network/ifcfg-* | \
302 sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
303 elif [ -f /etc/pld-release ]; then
304 # PLD Linux
305 COMPREPLY=( $( command ls -B \
306 /etc/sysconfig/interfaces | \
307 sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
308 else
309 # Assume Red Hat
310 COMPREPLY=( $( command ls \
311 /etc/sysconfig/network-scripts/ifcfg-* | \
312 sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ) )
313 fi
314 }
315
316 # This function completes on all available network interfaces
317 # -a: restrict to active interfaces only
318 # -w: restrict to wireless interfaces only
319 #
320 _available_interfaces()
321 {
322 local cmd
323
324 if [ "${1:-}" = -w ]; then
325 cmd="iwconfig"
326 elif [ "${1:-}" = -a ]; then
327 cmd="ifconfig"
328 else
329 cmd="ifconfig -a"
330 fi
331
332 COMPREPLY=( $( eval $cmd 2>/dev/null | \
333 sed -ne 's|^\('$cur'[^[:space:][:punct:]]\{1,\}\).*$|\1|p') )
334 }
335
336 # This function expands tildes in pathnames
337 #
338 _expand()
339 {
340 # FIXME: Why was this here?
341 # [ "$cur" != "${cur%\\}" ] && cur="$cur\\"
342
343 # expand ~username type directory specifications
344 if [[ "$cur" == \~*/* ]]; then
345 eval cur=$cur
346 elif [[ "$cur" == \~* ]]; then
347 cur=${cur#\~}
348 COMPREPLY=( $( compgen -P '~' -u $cur ) )
349 return ${#COMPREPLY[@]}
350 fi
351 }
352
353 # This function completes on process IDs.
354 # AIX and Solaris ps prefers X/Open syntax.
355 [ $UNAME = SunOS -o $UNAME = AIX ] &&
356 _pids()
357 {
358 COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- $cur ))
359 } ||
360 _pids()
361 {
362 COMPREPLY=( $( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ) )
363 }
364
365 # This function completes on process group IDs.
366 # AIX and SunOS prefer X/Open, all else should be BSD.
367 [ $UNAME = SunOS -o $UNAME = AIX ] &&
368 _pgids()
369 {
370 COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- $cur ))
371 } ||
372 _pgids()
373 {
374 COMPREPLY=( $( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur ))
375 }
376
377 # This function completes on user IDs
378 #
379 _uids()
380 {
381 if type getent &>/dev/null; then
382 COMPREPLY=( $( getent passwd | \
383 awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
384 elif type perl &>/dev/null; then
385 COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- $cur ) )
386 else
387 # make do with /etc/passwd
388 COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
389 /etc/passwd ) )
390 fi
391 }
392
393 # This function completes on group IDs
394 #
395 _gids()
396 {
397 if type getent &>/dev/null; then
398 COMPREPLY=( $( getent group | \
399 awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ) )
400 elif type perl &>/dev/null; then
401 COMPREPLY=( $( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- $cur ) )
402 else
403 # make do with /etc/group
404 COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'\
405 /etc/group ) )
406 fi
407 }
408
409 # This function completes on services
410 #
411 _services()
412 {
413 local sysvdir famdir
414 [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
415 famdir=/etc/xinetd.d
416 COMPREPLY=( $( builtin echo $sysvdir/!(*.rpmsave|*.rpmorig|*~|functions)) )
417
418 if [ -d $famdir ]; then
419 COMPREPLY=( "${COMPREPLY[@]}" $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) )
420 fi
421
422 COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ) )
423 }
424
425 # This function complete on modules
426 #
427 _modules()
428 {
429 local modpath
430 modpath=/lib/modules/$1
431 COMPREPLY=( $( command ls -R $modpath | \
432 sed -ne 's/^\('$cur'.*\)\.k\?o\(\|.gz\)$/\1/p') )
433 }
434
435 # this function complete on user:group format
436 #
437 _usergroup()
438 {
439 local IFS=$'\n'
440 cur=${cur//\\\\ / }
441 if [[ $cur = *@(\\:|.)* ]] && [ -n "$bash205" ]; then
442 user=${cur%%*([^:.])}
443 COMPREPLY=( $(compgen -P ${user/\\\\} -g -- ${cur##*[.:]}) )
444 elif [[ $cur = *:* ]] && [ -n "$bash205" ]; then
445 COMPREPLY=( $( compgen -g -- ${cur##*[.:]} ) )
446 else
447 COMPREPLY=( $( compgen -S : -u -- $cur ) )
448 fi
449 }
450
451 # this function count the number of mandatory args
452 #
453 _count_args()
454 {
455 args=1
456 for (( i=1; i < COMP_CWORD; i++ )); do
457 if [[ "${COMP_WORDS[i]}" != -* ]]; then
458 args=$(($args+1))
459 fi
460 done
461 }
462
463 # start of section containing completion functions for bash built-ins
464
465 # bash alias completion
466 #
467 _alias()
468 {
469 local cur
470
471 COMPREPLY=()
472 cur=${COMP_WORDS[$COMP_CWORD]}
473
474 case "$COMP_LINE" in
475 *[^=])
476 COMPREPLY=( $( compgen -A alias -S '=' -- $cur ) )
477 ;;
478 *=)
479 COMPREPLY=( "$( alias ${cur%=} 2>/dev/null | \
480 sed -e 's|^alias '$cur'\(.*\)$|\1|' )" )
481 ;;
482 esac
483 }
484 complete -F _alias $nospace alias
485
486 # bash export completion
487 #
488 _export()
489 {
490 local cur
491
492 COMPREPLY=()
493 cur=${COMP_WORDS[$COMP_CWORD]}
494
495 case "$COMP_LINE" in
496 *=\$*)
497 COMPREPLY=( $( compgen -v -P '$' -- ${cur#*=\$} ) )
498 ;;
499 *[^=])
500 COMPREPLY=( $( compgen -v -S '=' -- $cur ) )
501 ;;
502 *=)
503 COMPREPLY=( "$( eval echo -n \"$`echo ${cur%=}`\" |
504 ( echo -n \'
505 sed -e 's/'\''/'\''\\\'\'''\''/g'
506 echo -n \' ) )" )
507 ;;
508 esac
509 }
510 complete -F _export $default $nospace export
511
512 # bash shell function completion
513 #
514 _function()
515 {
516 local cur prev
517
518 COMPREPLY=()
519 cur=`_get_cword`
520 prev=${COMP_WORDS[COMP_CWORD-1]}
521
522 if [[ $1 == @(declare|typeset) ]]; then
523 if [ "$prev" = -f ]; then
524 COMPREPLY=( $( compgen -A function -- $cur ) )
525 elif [[ "$cur" == -* ]]; then
526 COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- \
527 $cur ) )
528 fi
529 elif [ $COMP_CWORD -eq 1 ]; then
530 COMPREPLY=( $( compgen -A function -- $cur ) )
531 else
532 COMPREPLY=( "() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )" )
533 fi
534 }
535 complete -F _function function declare typeset
536
537 # bash complete completion
538 #
539 _complete()
540 {
541 local cur prev options
542
543 COMPREPLY=()
544 cur=`_get_cword`
545 prev=${COMP_WORDS[COMP_CWORD-1]}
546
547 case $prev in
548 -o)
549 options="default dirnames filenames"
550 [ -n "$bash205b" ] && options="$options nospace"
551 [ -n "$bash3" ] && options="$options bashdefault plusdirs"
552 COMPREPLY=( $( compgen -W "$options" -- $cur ) )
553 return 0
554 ;;
555
556 -A)
557 COMPREPLY=( $( compgen -W 'alias arrayvar binding \
558 builtin command directory disabled enabled \
559 export file function group helptopic hostname \
560 job keyword running service setopt shopt \
561 signal stopped user variable' -- $cur ) )
562 return 0
563 ;;
564
565 -C)
566 COMPREPLY=( $( compgen -A command -- $cur ) )
567 return 0
568 ;;
569 -F)
570 COMPREPLY=( $( compgen -A function -- $cur ) )
571 return 0
572 ;;
573 -@(p|r))
574 COMPREPLY=( $( complete -p | sed -e 's|.* ||' | \
575 grep "^$cur" ) )
576 return 0
577 ;;
578
579 esac
580
581 if [[ "$cur" == -* ]]; then
582 # relevant options completion
583 options="-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C"
584 [ -n "$bash205" ] && options="$options -o"
585 COMPREPLY=( $( compgen -W "$options" -- $cur ) )
586 else
587 COMPREPLY=( $( compgen -A command -- $cur ) )
588 fi
589 }
590 complete -F _complete complete
591
592 # start of section containing completion functions for external programs
593
594 # a little help for FreeBSD ports users
595 [ $UNAME = FreeBSD ] && complete -W 'index search fetch fetch-list \
596 extract patch configure build install reinstall \
597 deinstall clean clean-depends kernel buildworld' make
598
599 # This completes on a list of all available service scripts for the
600 # 'service' command and/or the SysV init.d directory, followed by
601 # that script's available commands
602 #
603 { have service || [ -d /etc/init.d/ ]; } &&
604 _service()
605 {
606 local cur sysvdir
607
608 COMPREPLY=()
609 prev=${COMP_WORDS[COMP_CWORD-1]}
610 cur=`_get_cword`
611
612 # don't complete for things like killall, ssh and mysql if it's
613 # the standalone command, rather than the init script
614 [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0
615
616 # don't complete past 2nd token
617 [ $COMP_CWORD -gt 2 ] && return 0
618
619 [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
620 || sysvdir=/etc/init.d
621
622 if [[ $COMP_CWORD -eq 1 ]] && [[ $prev == "service" ]]; then
623 _services
624 else
625 COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
626 s/^.*Usage.*{\(.*\)}.*$/\1/p" \
627 $sysvdir/${prev##*/} 2>/dev/null`' -- $cur ) )
628 fi
629
630 return 0
631 } &&
632 complete -F _service service
633 [ -d /etc/init.d/ ] && complete -F _service $default \
634 $(for i in /etc/init.d/*; do echo ${i##*/}; done)
635
636 # chown(1) completion
637 #
638 _chown()
639 {
640 local cur
641 cur=`_get_cword`
642
643 # options completion
644 if [[ "$cur" == -* ]]; then
645 COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \
646 --dereference --no-dereference --from= --silent --quiet \
647 --reference= --recursive --verbose --help --version' -- $cur ) )
648 else
649 _count_args
650
651 case $args in
652 1)
653 _usergroup
654 ;;
655 *)
656 _filedir
657 ;;
658 esac
659 fi
660 }
661 complete -F _chown $filenames chown
662
663 # chgrp(1) completion
664 #
665 _chgrp()
666 {
667 local cur prev
668
669 COMPREPLY=()
670 cur=`_get_cword`
671 cur=${cur//\\\\/}
672 prev=${COMP_WORDS[COMP_CWORD-1]}
673
674 # options completion
675 if [[ "$cur" == -* ]]; then
676 COMPREPLY=( $( compgen -W '-c -h -f -R -v --changes \
677 --dereference --no-dereference --silent --quiet \
678 --reference= --recursive --verbose --help --version' -- $cur ) )
679 return 0
680 fi
681
682 # first parameter on line or first since an option?
683 if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || \
684 [[ "$prev" == -* ]] && [ -n "$bash205" ]; then
685 local IFS=$'\n'
686 COMPREPLY=( $( compgen -g $cur 2>/dev/null ) )
687 else
688 _filedir || return 0
689 fi
690
691 return 0
692 }
693 complete -F _chgrp $filenames chgrp
694
695 # umount(8) completion. This relies on the mount point being the third
696 # space-delimited field in the output of mount(8)
697 #
698 _umount()
699 {
700 local cur
701
702 COMPREPLY=()
703 cur=`_get_cword`
704
705 OLDIFS="$IFS"
706 IFS="\n"
707 COMPREPLY=( $( compgen -W '$( mount | cut -d" " -f 3 )' -- $cur ) )
708 IFS="$OLDIFS"
709
710 return 0
711 }
712 complete -F _umount $dirnames umount
713
714 # mount(8) completion. This will pull a list of possible mounts out of
715 # /etc/{,v}fstab, unless the word being completed contains a ':', which
716 # would indicate the specification of an NFS server. In that case, we
717 # query the server for a list of all available exports and complete on
718 # that instead.
719 #
720 _mount()
721 { local cur i sm host
722
723 COMPREPLY=()
724 cur=`_get_cword`
725 [[ "$cur" == \\ ]] && cur="/"
726
727 for i in {,/usr}/{,s}bin/showmount; do [ -x $i ] && sm=$i && break; done
728
729 if [ -n "$sm" ] && [[ "$cur" == *:* ]]; then
730 COMPREPLY=( $( $sm -e ${cur%%:*} | sed 1d | \
731 grep ^${cur#*:} | awk '{print $1}' ) )
732 elif [[ "$cur" == //* ]]; then
733 host=${cur#//}
734 host=${host%%/*}
735 if [ -n "$host" ]; then
736 COMPREPLY=( $( compgen -W "$( echo $( smbclient -d 0 -NL $host 2>/dev/null|
737 sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' |
738 sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|//'$host'/\1|p' ) )" -- "$cur" ) )
739 fi
740 elif [ -r /etc/vfstab ]; then
741 # Solaris
742 COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
743 /etc/vfstab | grep "^$cur" ) )
744 elif [ ! -e /etc/fstab ]; then
745 # probably Cygwin
746 COMPREPLY=( $( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' \
747 | grep "^$cur" ) )
748 else
749 # probably Linux
750 COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \
751 /etc/fstab | grep "^$cur" ) )
752 fi
753
754 return 0
755 }
756 complete -F _mount $default $filenames mount
757
758 # Linux rmmod(8) completion. This completes on a list of all currently
759 # installed kernel modules.
760 #
761 have rmmod && {
762 _rmmod()
763 {
764 local cur
765
766 COMPREPLY=()
767 cur=`_get_cword`
768
769 COMPREPLY=( $( /sbin/lsmod | \
770 awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' 2>/dev/null ))
771 return 0
772 }
773 complete -F _rmmod rmmod
774
775 # Linux insmod(8), modprobe(8) and modinfo(8) completion. This completes on a
776 # list of all available modules for the version of the kernel currently
777 # running.
778 #
779 _insmod()
780 {
781 local cur prev modpath
782
783 COMPREPLY=()
784 cur=`_get_cword`
785 prev=${COMP_WORDS[COMP_CWORD-1]}
786
787 # behave like lsmod for modprobe -r
788 if [ $1 = "modprobe" ] &&
789 [ "${COMP_WORDS[1]}" = "-r" ]; then
790 COMPREPLY=( $( /sbin/lsmod | \
791 awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' ) )
792 return 0
793 fi
794
795 # do filename completion if we're giving a path to a module
796 if [[ "$cur" == */* ]]; then
797 _filedir '@(?(k)o?(.gz))'
798 return 0
799 fi
800
801 if [ $COMP_CWORD -gt 1 ] &&
802 [[ "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then
803 # do module parameter completion
804 COMPREPLY=( $( /sbin/modinfo -p ${COMP_WORDS[1]} 2>/dev/null | \
805 awk '{if ($1 ~ /^parm:/ && $2 ~ /^'$cur'/) { print $2 } \
806 else if ($1 !~ /:/ && $1 ~ /^'$cur'/) { print $1 }}' ) )
807 else
808 _modules $(uname -r)
809 fi
810
811 return 0
812 }
813 complete -F _insmod $filenames insmod modprobe modinfo
814 }
815
816 # man(1) completion
817 #
818 [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
819 -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
820 -o $UNAME = OpenBSD ] &&
821 _man()
822 {
823 local cur prev sect manpath UNAME
824
825 COMPREPLY=()
826 cur=`_get_cword`
827 prev=${COMP_WORDS[COMP_CWORD-1]}
828
829 _expand || return 0
830
831 # default completion if parameter contains /
832 if [[ "$cur" == */* ]]; then
833 _filedir
834 return 0
835 fi
836
837 UNAME=$( uname -s )
838 # strip OS type and version under Cygwin
839 UNAME=${UNAME/CYGWIN_*/Cygwin}
840 if [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = FreeBSD \
841 -o $UNAME = Cygwin ]; then
842 manpath=$( manpath 2>/dev/null || command man --path )
843 else
844 manpath=$MANPATH
845 fi
846
847 if [ -z "$manpath" ]; then
848 COMPREPLY=( $( compgen -c -- $cur ) )
849 return 0
850 fi
851
852 # determine manual section to search
853 [[ "$prev" == [0-9ln] ]] && sect=$prev || sect='*'
854
855 manpath=$manpath:
856 if [ -n "$cur" ]; then
857 manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"
858 else
859 manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
860 fi
861
862 # redirect stderr for when path doesn't exist
863 COMPREPLY=( $( eval command ls "$manpath" 2>/dev/null ) )
864 # weed out directory path names and paths to man pages
865 COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
866 # strip suffix from man pages
867 COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} )
868 COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
869
870 [[ "$prev" != [0-9ln] ]] && _filedir '[0-9ln]'
871
872 return 0
873 }
874 [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Darwin \
875 -o $UNAME = FreeBSD -o $UNAME = SunOS -o $UNAME = Cygwin \
876 -o $UNAME = OpenBSD ] && \
877 complete -F _man $filenames man apropos whatis
878
879 # renice(8) completion
880 #
881 _renice()
882 {
883 local command cur curopt i
884
885 COMPREPLY=()
886 cur=`_get_cword`
887 command=$1
888
889 i=0
890 # walk back through command line and find last option
891 while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
892 curopt=${COMP_WORDS[COMP_CWORD-$i]}
893 case "$curopt" in
894 -u)
895 COMPREPLY=( $( compgen -u -- $cur ) )
896 ;;
897 -g)
898 _pgids
899 ;;
900 -p|$command)
901 _pids
902 ;;
903 esac
904 i=$(( ++i ))
905 done
906 }
907 complete -F _renice renice
908
909 # kill(1) completion
910 #
911 _kill()
912 {
913 local cur
914
915 COMPREPLY=()
916 cur=`_get_cword`
917
918 if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
919 # return list of available signals
920 _signals
921 else
922 # return list of available PIDs
923 _pids
924 fi
925 }
926 complete -F _kill kill
927
928 # Linux and FreeBSD killall(1) completion.
929 #
930 [ $UNAME = Linux -o $UNAME = FreeBSD ] &&
931 _killall()
932 {
933 local cur
934
935 COMPREPLY=()
936 cur=`_get_cword`
937
938 if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
939 _signals
940 else
941 COMPREPLY=( $( compgen -W '$( command ps axo command | \
942 sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
943 sed -e "s/.*\///" )' -- $cur ) )
944 fi
945
946 return 0
947 }
948 [ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall pkill
949
950 # Linux and FreeBSD pgrep(1) completion.
951 #
952 [ $UNAME = Linux -o $UNAME = FreeBSD ] &&
953 _pgrep()
954 {
955 local cur
956
957 COMPREPLY=()
958 cur=`_get_cword`
959
960 COMPREPLY=( $( compgen -W '$( command ps axo command | \
961 sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
962 sed -e "s/.*\///" )' -- $cur ) )
963
964 return 0
965 }
966 [ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _pgrep pgrep
967 # Linux pidof(8) completion.
968 [ $UNAME = Linux ] && complete -F _pgrep pidof
969
970 # GNU find(1) completion. This makes heavy use of ksh style extended
971 # globs and contains Linux specific code for completing the parameter
972 # to the -fstype option.
973 #
974 _find()
975 {
976 local cur prev i exprfound onlyonce
977
978 COMPREPLY=()
979 cur=`_get_cword`
980 prev=${COMP_WORDS[COMP_CWORD-1]}
981
982 case "$prev" in
983 -@(max|min)depth)
984 COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9' -- $cur ) )
985 return 0
986 ;;
987 -?(a|c)newer|-fls|-fprint?(0|f)|-?(i)?(l)name|-?(i)wholename)
988 _filedir
989 return 0
990 ;;
991 -fstype)
992 # this is highly non-portable
993 [ -e /proc/filesystems ] &&
994 COMPREPLY=( $( cut -d$'\t' -f 2 /proc/filesystems | \
995 grep "^$cur" ) )
996 return 0
997 ;;
998 -gid)
999 _gids
1000 return 0
1001 ;;
1002 -group)
1003 if [ -n "$bash205" ]; then
1004 COMPREPLY=( $( compgen -g -- $cur 2>/dev/null) )
1005 fi
1006 return 0
1007 ;;
1008 -?(x)type)
1009 COMPREPLY=( $( compgen -W 'b c d p f l s' -- $cur ) )
1010 return 0
1011 ;;
1012 -uid)
1013 _uids
1014 return 0
1015 ;;
1016 -user)
1017 COMPREPLY=( $( compgen -u -- $cur ) )
1018 return 0
1019 ;;
1020 -exec|-ok)
1021 COMP_WORDS=(COMP_WORDS[0] $cur)
1022 COMP_CWORD=1
1023 _command
1024 return 0
1025 ;;
1026 -[acm]min|-[acm]time|-?(i)?(l)name|-inum|-?(i)path|-?(i)regex| \
1027 -links|-perm|-size|-used|-printf)
1028 # do nothing, just wait for a parameter to be given
1029 return 0
1030 ;;
1031 esac
1032
1033 _expand || return 0
1034
1035 # set exprfound to 1 if there is already an expression present
1036 for i in ${COMP_WORDS[@]}; do
1037 [[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break
1038 done
1039
1040 # handle case where first parameter is not a dash option
1041 if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then
1042 _filedir -d
1043 return 0
1044 fi
1045
1046 # complete using basic options
1047 COMPREPLY=( $( compgen -W '-daystart -depth -follow -help -maxdepth \
1048 -mindepth -mount -noleaf -version -xdev -amin -anewer \
1049 -atime -cmin -cnewer -ctime -empty -false -fstype \
1050 -gid -group -ilname -iname -inum -ipath -iregex \
1051 -wholename \
1052 -links -lname -mmin -mtime -name -newer -nouser \
1053 -nogroup -perm -regex -size -true -type -uid -used \
1054 -user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \
1055 -print -print0 -printf -prune -ls' -- $cur ) )
1056
1057 # this removes any options from the list of completions that have
1058 # already been specified somewhere on the command line, as long as
1059 # these options can only be used once (in a word, "options", in
1060 # opposition to "tests" and "actions", as in the find(1) manpage).
1061 onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \
1062 -noleaf -version -xdev '
1063 COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \
1064 (while read -d ' ' i; do
1065 [ "$i" == "" ] ||
1066 [ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] &&
1067 continue
1068 # flatten array with spaces on either side,
1069 # otherwise we cannot grep on word boundaries of
1070 # first and last word
1071 COMPREPLY=" ${COMPREPLY[@]} "
1072 # remove word from list of completions
1073 COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
1074 done
1075 echo "${COMPREPLY[@]}")
1076 ) )
1077
1078 _filedir
1079
1080 return 0
1081 }
1082 complete -F _find $filenames find
1083
1084 # Linux iwconfig(8) completion
1085 #
1086 [ $UNAME = Linux ] && have iwconfig &&
1087 _iwconfig()
1088 {
1089 local cur prev
1090
1091 COMPREPLY=()
1092 cur=`_get_cword`
1093 prev=${COMP_WORDS[COMP_CWORD-1]}
1094
1095 case $prev in
1096 mode)
1097 COMPREPLY=( $( compgen -W 'managed ad-hoc master \
1098 repeater secondary monitor' -- $cur ) )
1099 return 0
1100 ;;
1101 essid)
1102 COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
1103 if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
1104 COMPREPLY=( "${COMPREPLY[@]}" \
1105 $( iwlist ${COMP_WORDS[1]} scan | \
1106 awk -F '"' '/ESSID/ {print $2}' | \
1107 grep "^$cur" ))
1108 fi
1109 return 0
1110 ;;
1111 nwid)
1112 COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
1113 return 0
1114 ;;
1115 channel)
1116 COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \
1117 awk '/^[[:space:]]*Channel/ {print $2}' | \
1118 grep "^$cur" ) )
1119 return 0
1120 ;;
1121
1122 freq)
1123 COMPREPLY=( $( iwlist ${COMP_WORDS[1]} channel | \
1124 awk '/^[[:space:]]*Channel/ {print $4"G"}' | \
1125 grep "^$cur" ) )
1126 return 0
1127 ;;
1128 ap)
1129 COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
1130 if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
1131 COMPREPLY=( "${COMPREPLY[@]}" \
1132 $( iwlist ${COMP_WORDS[1]} scan | \
1133 awk -F ': ' '/Address/ {print $2}' | \
1134 grep "^$cur" ) )
1135 fi
1136 return 0
1137 ;;
1138 rate)
1139 COMPREPLY=( $( compgen -W 'auto fixed' -- $cur ) )
1140 COMPREPLY=( "${COMPREPLY[@]}" \
1141 $( iwlist ${COMP_WORDS[1]} rate | \
1142 awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | \
1143 grep "^$cur" ) )
1144 return 0
1145 ;;
1146 rts)
1147 COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
1148 return 0
1149 ;;
1150 frag)
1151 COMPREPLY=( $( compgen -W 'auto fixed off' -- $cur ) )
1152 return 0
1153 ;;
1154 key)
1155 COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
1156 return 0
1157 ;;
1158 enc)
1159 COMPREPLY=( $( compgen -W 'off on open restricted' -- $cur ) )
1160 return 0
1161 ;;
1162 power)
1163 COMPREPLY=( $( compgen -W 'period timeout off on' -- $cur ) )
1164 return 0
1165 ;;
1166 txpower)
1167 COMPREPLY=( $( compgen -W 'off on auto' -- $cur ) )
1168 return 0
1169 ;;
1170 retry)
1171 COMPREPLY=( $( compgen -W 'limit lifetime' -- $cur ) )
1172 return 0
1173 ;;
1174 esac
1175
1176 if [ $COMP_CWORD -eq 1 ]; then
1177 if [[ "$cur" == -* ]]; then
1178 COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
1179 else
1180 _available_interfaces -w
1181 fi
1182 else
1183 COMPREPLY=( $( compgen -W 'essid nwid mode freq channel sens mode \
1184 ap nick rate rts frag enc key power txpower commit' -- $cur ) )
1185 fi
1186
1187 } &&
1188 complete -F _iwconfig iwconfig
1189
1190 # Linux iwlist(8) completion
1191 #
1192 [ $UNAME = Linux ] && have iwlist &&
1193 _iwlist()
1194 {
1195 local cur prev
1196
1197 COMPREPLY=()
1198 cur=`_get_cword`
1199 prev=${COMP_WORDS[COMP_CWORD-1]}
1200
1201 if [ $COMP_CWORD -eq 1 ]; then
1202 if [[ "$cur" == -* ]]; then
1203 COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
1204 else
1205 _available_interfaces -w
1206 fi
1207 else
1208 COMPREPLY=( $( compgen -W 'scan scanning freq frequency \
1209 channel rate bit bitrate key enc encryption power \
1210 txpower retry ap accesspoint peers event' -- $cur ) )
1211 fi
1212 } &&
1213 complete -F _iwlist iwlist
1214
1215 # Linux iwspy(8) completion
1216 #
1217 [ $UNAME = Linux ] && have iwspy &&
1218 _iwspy()
1219 {
1220 local cur
1221
1222 COMPREPLY=()
1223 cur=`_get_cword`
1224
1225 if [ $COMP_CWORD -eq 1 ]; then
1226 if [[ "$cur" == -* ]]; then
1227 COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
1228 else
1229 _available_interfaces -w
1230 fi
1231 else
1232 COMPREPLY=( $( compgen -W 'setthr getthr off' -- $cur ) )
1233 fi
1234 } &&
1235 complete -F _iwspy iwspy
1236
1237 # Linux iwpriv(8) completion
1238 #
1239 [ $UNAME = Linux ] && have iwpriv &&
1240 _iwpriv()
1241 {
1242 local cur prev
1243
1244 COMPREPLY=()
1245 cur=`_get_cword`
1246 prev=${COMP_WORDS[COMP_CWORD-1]}
1247
1248 case "$prev" in
1249 roam)
1250 COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
1251 return 0
1252 ;;
1253 port)
1254 COMPREPLY=( $( compgen -W 'ad-hoc managed' -- $cur ) )
1255 return 0
1256 ;;
1257 esac
1258
1259 if [ $COMP_CWORD -eq 1 ]; then
1260 if [[ "$cur" == -* ]]; then
1261 COMPREPLY=( $( compgen -W '--help --version' -- $cur ) )
1262 else
1263 _available_interfaces -w
1264 fi
1265 else
1266 COMPREPLY=( $( compgen -W '--all roam port' -- $cur ) )
1267 fi
1268 } &&
1269 complete -F _iwpriv iwpriv
1270
1271 # RedHat & Debian GNU/Linux if{up,down} completion
1272 #
1273 [ $UNAME = Linux ] && { have ifup || have ifdown; } &&
1274 _ifupdown()
1275 {
1276 local cur
1277
1278 COMPREPLY=()
1279 cur=`_get_cword`
1280
1281 if [ $COMP_CWORD -eq 1 ]; then
1282 _configured_interfaces
1283 COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") )
1284 fi
1285
1286 return 0
1287 } &&
1288 complete -F _ifupdown ifup ifdown
1289 [ $UNAME = Linux ] && have ifstatus && complete -F _ifupdown ifstatus
1290
1291 # Linux ipsec(8) completion (for FreeS/WAN)
1292 #
1293 [ $UNAME = Linux ] && have ipsec &&
1294 _ipsec()
1295 {
1296 local cur
1297
1298 COMPREPLY=()
1299 cur=`_get_cword`
1300
1301
1302 if [ $COMP_CWORD -eq 1 ]; then
1303 COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look \
1304 manual pluto ranbits rsasigkey \
1305 setup showdefaults showhostkey spi \
1306 spigrp tncfg whack' -- $cur ) )
1307 return 0
1308 fi
1309
1310 case ${COMP_WORDS[1]} in
1311 auto)
1312 COMPREPLY=( $( compgen -W '--asynchronous --up --add --delete \
1313 --replace --down --route --unroute \
1314 --ready --status --rereadsecrets' \
1315 -- $cur ) )
1316 ;;
1317 manual)
1318 COMPREPLY=( $( compgen -W '--up --down --route --unroute \
1319 --union' -- $cur ) )
1320 ;;
1321 ranbits)
1322 COMPREPLY=( $( compgen -W '--quick --continuous --bytes' \
1323 -- $cur ) )
1324 ;;
1325 setup)
1326 COMPREPLY=( $( compgen -W '--start --stop --restart' -- $cur ) )
1327 ;;
1328
1329 *)
1330 ;;
1331 esac
1332
1333 return 0
1334 } &&
1335 complete -F _ipsec ipsec
1336
1337 # Postfix completion.
1338 #
1339 have postfix && {
1340 # postfix(1)
1341 #
1342 _postfix()
1343 {
1344 local cur prev
1345
1346 cur=`_get_cword`
1347 prev=${COMP_WORDS[COMP_CWORD-1]}
1348
1349 if [[ $cur == '-' ]]; then
1350 COMPREPLY=(-c -D -v)
1351 return 0
1352 fi
1353 if [[ $prev == '-c' ]]; then
1354 _filedir -d
1355 return 0
1356 fi
1357 if [[ $prev == '-D' ]]; then
1358 COMPREPLY=( $( compgen -W 'start' -- "`get_cword`" ) )
1359 return 0
1360 fi
1361 COMPREPLY=( $( compgen -W 'start stop reload abort flush check' -- \
1362 "`get_cword`" ) )
1363 }
1364 complete -F _postfix postfix
1365
1366 # postalias(1) and postmap(1)
1367 #
1368 _postmap()
1369 {
1370 local cur prev len idx
1371
1372 cur=`_get_cword`
1373 prev=${COMP_WORDS[COMP_CWORD-1]}
1374
1375 if [[ $cur == '-' ]]; then
1376 COMPREPLY=(-N -f -i -n -o -p -r -v -w -c -d -q)
1377 return 0
1378 fi
1379 if [[ $prev == '-c' ]]; then
1380 _filedir -d
1381 return 0
1382 fi
1383 if [[ $prev == -[dq] ]]; then
1384 return 0
1385 fi
1386
1387 if [[ "$cur" == *:* ]]; then
1388 COMPREPLY=( $( compgen -f -- ${cur#*:} ) )
1389 else
1390 len=${#cur}
1391 idx=0
1392 for pval in $( /usr/sbin/postconf -m ); do
1393 if [[ "$cur" == "${pval:0:$len}" ]]; then
1394 COMPREPLY[$idx]="$pval:"
1395 idx=$(($idx+1))
1396 fi
1397 done
1398 if [[ $idx -eq 0 ]]; then
1399 COMPREPLY=( $( compgen -f -- "$cur" ) )
1400 fi
1401 fi
1402 return 0
1403 }
1404 complete -F _postmap postmap postalias
1405
1406 # postcat(1)
1407 #
1408 _postcat()
1409 {
1410 local cur prev pval len idx qfile
1411
1412 cur=`_get_cword`
1413 prev=${COMP_WORDS[COMP_CWORD-1]}
1414
1415 if [[ $cur == '-' ]]; then
1416 COMPREPLY=(-c -q -v)
1417 return 0
1418 fi
1419 if [[ $prev == '-c' ]]; then
1420 _filedir -d
1421 return 0
1422 fi
1423
1424 qfile=0
1425 for idx in "${COMP_WORDS[@]}"; do
1426 [[ "$idx" = -q ]] && qfile=1 && break
1427 done
1428 if [[ $qfile == 1 ]]; then
1429 len=${#cur}
1430 idx=0
1431 for pval in $( mailq | \
1432 sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
1433 if [[ "$cur" == "${pval:0:$len}" ]]; then
1434 COMPREPLY[$idx]=$pval
1435 idx=$(($idx+1))
1436 fi
1437 done
1438 return 0
1439 else
1440 _filedir
1441 return 0
1442 fi
1443 }
1444 complete -F _postcat postcat
1445
1446 # postconf(1)
1447 #
1448 _postconf()
1449 {
1450 local cur prev pval len idx eqext
1451
1452 cur=`_get_cword`
1453 prev=${COMP_WORDS[COMP_CWORD-1]}
1454 if [[ $cur == '-' ]]; then
1455 COMPREPLY=(-c -d -e -h -m -l -n -v)
1456 return 0
1457 fi
1458 if [[ $prev == '-c' ]]; then
1459 _filedir -d
1460 return 0
1461 fi
1462 if [[ $prev == '-e' ]]; then
1463 cur=${cur#[\"\']}
1464 eqext='='
1465 fi
1466 len=${#cur}
1467 idx=0
1468 for pval in $( /usr/sbin/postconf | cut -d ' ' -f 1 ); do
1469 if [[ "$cur" == "${pval:0:$len}" ]]; then
1470 COMPREPLY[$idx]="$pval$eqext"
1471 idx=$(($idx+1))
1472 fi
1473 done
1474 return 0
1475 }
1476 complete -F _postconf postconf
1477
1478 # postsuper(1)
1479 #
1480 _postsuper()
1481 {
1482 local cur prev pval len idx
1483
1484 cur=`_get_cword`
1485 prev=${COMP_WORDS[COMP_CWORD-1]}
1486
1487 if [[ $cur == '-' ]]; then
1488 COMPREPLY=(-c -d -h -H -p -r -s -v)
1489 return 0
1490 fi
1491 case $prev in
1492 -[dr])
1493 len=${#cur}
1494 idx=0
1495 for pval in $( echo ALL; mailq | \
1496 sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* !].*$//' ); do
1497 if [[ "$cur" == "${pval:0:$len}" ]]; then
1498 COMPREPLY[$idx]=$pval
1499 idx=$(($idx+1))
1500 fi
1501 done
1502 return 0
1503 ;;
1504 -h)
1505 len=${#cur}
1506 idx=0
1507 for pval in $( echo ALL; mailq | \
1508 sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; s/[* ].*$//; /!$/d' ); do
1509 if [[ "$cur" == "${pval:0:$len}" ]]; then
1510 COMPREPLY[$idx]=$pval
1511 idx=$(($idx+1))
1512 fi
1513 done
1514 return 0
1515 ;;
1516 -H)
1517 len=${#cur}
1518 idx=0
1519 for pval in $( echo ALL; mailq | \
1520 sed -e '1d; $d; /^[^0-9A-Z]\|^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//' ); do
1521 if [[ "$cur" == "${pval:0:$len}" ]]; then
1522 COMPREPLY[$idx]=$pval
1523 idx=$(($idx+1))
1524 fi
1525 done
1526 return 0
1527 ;;
1528 esac
1529 COMPREPLY=( $( compgen -W 'hold incoming active deferred' -- $cur ) )
1530 return 0
1531 }
1532 complete -F _postsuper postsuper
1533 }
1534
1535 # cvs(1) completion
1536 #
1537 have cvs && {
1538 set_prefix()
1539 {
1540 [ -z ${prefix:-} ] || prefix=${cur%/*}/
1541 [ -r ${prefix:-}CVS/Entries ] || prefix=""
1542 }
1543
1544 get_entries()
1545 {
1546 local IFS=$'\n'
1547 [ -r ${prefix:-}CVS/Entries ] && \
1548 entries=$(cut -d/ -f2 -s ${prefix:-}CVS/Entries)
1549 }
1550
1551 get_modules()
1552 {
1553 if [ -n "$prefix" ]; then
1554 COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) )
1555 else
1556 COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) )
1557 fi
1558 }
1559
1560 _cvs()
1561 {
1562 local cur count mode i cvsroot cvsroots pwd
1563 local -a flags miss files entries changed newremoved
1564
1565 COMPREPLY=()
1566 cur=`_get_cword`
1567
1568 count=0
1569 for i in "${COMP_WORDS[@]}"; do
1570 [ $count -eq $COMP_CWORD ] && break
1571 # Last parameter was the CVSROOT, now go back to mode selection
1572 if [ "${COMP_WORDS[((count))]}" == "$cvsroot" -a "$mode" == "cvsroot" ]; then
1573 mode=""
1574 fi
1575 if [ -z "$mode" ]; then
1576 case $i in
1577 -d)
1578 mode=cvsroot
1579 cvsroot=${COMP_WORDS[((count+1))]}
1580 ;;
1581 @(ad?(d)|new))
1582 mode=add
1583 ;;
1584 @(adm?(in)|rcs))
1585 mode=admin
1586 ;;
1587 ann?(notate))
1588 mode=annotate
1589 ;;
1590 @(checkout|co|get))
1591 mode=checkout
1592 ;;
1593 @(com?(mit)|ci))
1594 mode=commit
1595 ;;
1596 di?(f?(f)))
1597 mode=diff
1598 ;;
1599 ex?(p?(ort)))
1600 mode=export
1601 ;;
1602 ?(un)edit)
1603 mode=$i
1604 ;;
1605 hi?(s?(tory)))
1606 mode=history
1607 ;;
1608 im?(p?(ort)))
1609 mode=import
1610 ;;
1611 re?(l?(ease)))
1612 mode=release
1613 ;;
1614 ?(r)log)
1615 mode=log
1616 ;;
1617 @(rdiff|patch))
1618 mode=rdiff
1619 ;;
1620 @(remove|rm|delete))
1621 mode=remove
1622 ;;
1623 @(rtag|rfreeze))
1624 mode=rtag
1625 ;;
1626 st?(at?(us)))
1627 mode=status
1628 ;;
1629 @(tag|freeze))
1630 mode=tag
1631 ;;
1632 up?(d?(ate)))
1633 mode=update
1634 ;;
1635 *)
1636 ;;
1637 esac
1638 elif [[ "$i" = -* ]]; then
1639 flags=( "${flags[@]}" $i )
1640 fi
1641 count=$((++count))
1642 done
1643
1644 case "$mode" in
1645 add)
1646 if [[ "$cur" != -* ]]; then
1647 set_prefix
1648 if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
1649 get_entries
1650 [ -z "$cur" ] && \
1651 files=$( command ls -Ad !(CVS) ) || \
1652 files=$( command ls -d ${cur}* 2>/dev/null )
1653 for i in "${entries[@]}"; do
1654 files=( ${files[@]/#$i//} )
1655 done
1656 COMPREPLY=( $( compgen -W '${files[@]}' -- \
1657 $cur ) )
1658 fi
1659 else
1660 COMPREPLY=( $( compgen -W '-k -m' -- $cur ) )
1661 fi
1662 ;;
1663 admin)
1664 if [[ "$cur" = -* ]]; then
1665 COMPREPLY=( $( compgen -W '-i -a -A -e -b -c -k -l -u \
1666 -L -U -m -M -n -N -o -q -I \
1667 -s -t -t- -T -V -x -z' -- \
1668 $cur ) )
1669 fi
1670 ;;
1671 annotate)
1672 if [[ "$cur" = -* ]]; then
1673 COMPREPLY=( $( compgen -W '-D -F -f -l -R -r' -- $cur ) )
1674 else
1675 get_entries
1676 COMPREPLY=( $( compgen -W '${entries[@]}' -- $cur ) )
1677 fi
1678 ;;
1679 checkout)
1680 if [[ "$cur" != -* ]]; then
1681 [ -z "$cvsroot" ] && cvsroot=$CVSROOT
1682 COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \
1683 awk '{print $1}' ) )
1684 COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
1685 else
1686 COMPREPLY=( $( compgen -W '-A -N -P -R -c -f -l -n -p \
1687 -s -r -D -d -k -j' -- $cur ) )
1688 fi
1689 ;;
1690 commit)
1691 set_prefix
1692
1693 if [[ "$cur" != -* ]] && [ -r ${prefix:-}CVS/Entries ]; then
1694 # if $COMP_CVS_REMOTE is not null, 'cvs commit' will
1695 # complete on remotely checked-out files (requires
1696 # passwordless access to the remote repository
1697 if [ -n "${COMP_CVS_REMOTE:-}" ]; then
1698 # this is the least computationally intensive
1699 # way found so far, but other changes
1700 # (something other than changed/removed/new)
1701 # may be missing
1702 changed=( $( cvs -q diff --brief 2>&1 | \
1703 sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ) )
1704 newremoved=( $( cvs -q diff --brief 2>&1 | \
1705 sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ) )
1706 COMPREPLY=( $( compgen -W '${changed[@]:-} \
1707 ${newremoved[@]:-}' -- $cur ) )
1708 else
1709 _filedir
1710 fi
1711 else
1712 COMPREPLY=( $( compgen -W '-n -R -l -f -F -m -r' -- \
1713 $cur ) )
1714 fi
1715 ;;
1716 cvsroot)
1717 if [ -r ~/.cvspass ]; then
1718 # Ugly escaping because of bash treating ':' specially
1719 cvsroots=$( sed 's/^[^ ]* //; s/:/\\:/g' ~/.cvspass )
1720 COMPREPLY=( $( compgen -W '$cvsroots' -- $cur ) )
1721 fi
1722 ;;
1723 export)
1724 if [[ "$cur" != -* ]]; then
1725 [ -z "$cvsroot" ] && cvsroot=$CVSROOT
1726 COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) )
1727 COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) )
1728 else
1729 COMPREPLY=( $( compgen -W '-N -f -l -R -n \
1730 -r -D -d -k' -- $cur ) )
1731 fi
1732 ;;
1733 diff)
1734 if [[ "$cur" == -* ]]; then
1735 _longopt diff
1736 else
1737 get_entries
1738 COMPREPLY=( $( compgen -W '${entries[@]:-}' -- $cur ) )
1739 fi
1740 ;;
1741 remove)
1742 if [[ "$cur" != -* ]]; then
1743 set_prefix
1744 if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
1745 get_entries
1746 # find out what files are missing
1747 for i in "${entries[@]}"; do
1748 [ ! -r "$i" ] && miss=( "${miss[@]}" $i )
1749 done
1750 COMPREPLY=( $(compgen -W '${miss[@]:-}' -- $cur) )
1751 fi
1752 else
1753 COMPREPLY=( $( compgen -W '-f -l -R' -- $cur ) )
1754 fi
1755 ;;
1756 import)
1757 if [[ "$cur" != -* ]]; then
1758 # starts with same algorithm as checkout
1759 [ -z "$cvsroot" ] && cvsroot=$CVSROOT
1760 prefix=${cur%/*}
1761 if [ -r ${cvsroot}/${prefix} ]; then
1762 get_modules
1763 COMPREPLY=( ${COMPREPLY[@]#$cvsroot} )
1764 COMPREPLY=( ${COMPREPLY[@]#\/} )
1765 fi
1766 pwd=$( pwd )
1767 pwd=${pwd##*/}
1768 COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- \
1769 $cur ) )
1770 else
1771 COMPREPLY=( $( compgen -W '-d -k -I -b -m -W' -- $cur ))
1772 fi
1773 ;;
1774 update)
1775 if [[ "$cur" = -* ]]; then
1776 COMPREPLY=( $( compgen -W '-A -P -C -d -f -l -R -p \
1777 -k -r -D -j -I -W' -- \
1778 $cur ) )
1779 fi
1780 ;;
1781 "")
1782 COMPREPLY=( $( compgen -W 'add admin annotate checkout ci co \
1783 commit diff delete edit export \
1784 freeze get history import log new \
1785 patch rcs rdiff release remove \
1786 rfreeze rlog rm rtag stat status \
1787 tag unedit up update -H -Q -q -b \
1788 -d -e -f -l -n -t -r -v -w -x -z \
1789 --help --version' -- $cur ) )
1790 ;;
1791 *)
1792 ;;
1793 esac
1794
1795 return 0
1796 }
1797 complete -F _cvs $default cvs
1798 }
1799
1800 have rpm && {
1801 # helper functions for rpm completion
1802 #
1803 _rpm_installed_packages()
1804 {
1805 local ver nodig nosig
1806
1807 if [ -r /var/log/rpmpkgs -a \
1808 /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
1809 # using RHL 7.2 or later - this is quicker than querying the DB
1810 COMPREPLY=( $( sed -ne \
1811 's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+.*\.rpm$|\1|p' \
1812 /var/log/rpmpkgs ) )
1813 else
1814 nodig=""
1815 nosig=""
1816 ver=$(rpm --version)
1817 ver=${ver##* }
1818
1819 if [[ "$ver" > "4.0.4" ]]; then
1820 nodig="--nodigest"
1821 fi
1822 if [[ "$ver" > "4.0.99" ]]; then
1823 nosig="--nosignature"
1824 fi
1825
1826 COMPREPLY=( $( rpm -qa $nodig $nosig | sed -ne \
1827 's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+$|\1|p' ) )
1828 fi
1829 }
1830
1831 _rpm_groups()
1832 {
1833 local IFS=$'\t'
1834 # remove trailing backslash, or grep will complain
1835 cur=${cur%"\\"}
1836 COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
1837 grep "^$cur" ) )
1838 # backslash escape spaces and translate newlines to tabs
1839 COMPREPLY=( $( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ) )
1840 }
1841
1842 # rpm(8) completion
1843 #
1844 _rpm()
1845 {
1846 local cur prev ver nodig nosig
1847
1848 COMPREPLY=()
1849 cur=`_get_cword`
1850 prev=${COMP_WORDS[COMP_CWORD-1]}
1851 nodig=""
1852 nosig=""
1853 ver=$(rpm --version); ver=${ver##* }
1854
1855 if [[ "$ver" > "4.0.4" ]]; then
1856 nodig="--nodigest"
1857 fi
1858 if [[ "$ver" > "4.0.99" ]]; then
1859 nosig="--nosignature"
1860 fi
1861
1862 if [ $COMP_CWORD -eq 1 ]; then
1863 # first parameter on line
1864 case "$cur" in
1865 -b*)
1866 COMPREPLY=( $( compgen -W '-ba -bb -bc -bi -bl -bp -bs'\
1867 -- $cur ) )
1868 ;;
1869 -t*)
1870 COMPREPLY=( $( compgen -W '-ta -tb -tc -ti -tl -tp -ts'\
1871 -- $cur ) )
1872 ;;
1873 --*)
1874 COMPREPLY=( $( compgen -W '--help --version --initdb \
1875 --checksig --recompile --rebuild --resign --addsign \
1876 --rebuilddb --showrc --setperms --setugids --tarbuild \
1877 --eval --install --upgrade --query --freshen --erase \
1878 --verify --querytags --rmsource --rmspec --clean \
1879 --import' -- $cur ) )
1880 ;;
1881 *)
1882 COMPREPLY=( $( compgen -W '-b -e -F -i -q -t -U -V' \
1883 -- $cur ) )
1884 ;;
1885 esac
1886
1887 return 0
1888 fi
1889
1890 case "$prev" in
1891 --@(@(db|exclude)path|prefix|relocate|root))
1892 _filedir -d
1893 return 0
1894 ;;
1895 --eval)
1896 # get a list of macros
1897 COMPREPLY=( $( sed -ne 's|^\(%'${cur#\%}'[^ '$'\t'']*\).*$|\1|p' \
1898 /usr/lib/rpm/macros ) )
1899 return 0
1900 ;;
1901 --pipe)
1902 COMPREPLY=( $( compgen -c -- $cur ) )
1903 return 0
1904 ;;
1905 --rcfile)
1906 _filedir
1907 return 0
1908 ;;
1909 --specfile)
1910 # complete on .spec files
1911 _filedir spec
1912 return 0
1913 ;;
1914 --whatprovides)
1915 if [[ "$cur" == */* ]]; then
1916 _filedir
1917 else
1918 # complete on capabilities
1919 COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \
1920 '%{providename}\n' | grep "^$cur" ) )
1921 fi
1922 return 0
1923 ;;
1924 --whatrequires)
1925 # complete on capabilities
1926 COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat \
1927 '%{requirename}\n' | grep "^$cur" ) )
1928 return 0
1929 ;;
1930 esac
1931
1932 case "${COMP_WORDS[1]}" in
1933 -@([iFU]*|-install|-freshen|-upgrade))
1934 if [[ "$cur" == -* ]]; then
1935 COMPREPLY=( $( compgen -W '--percent --force --test \
1936 --replacepkgs --replacefiles --root --excludedocs \
1937 --includedocs --noscripts --rcfile --ignorearch \
1938 --dbpath --prefix --ignoreos --nodeps --allfiles \
1939 --ftpproxy --ftpport --justdb --httpproxy --httpport \
1940 --noorder --relocate --badreloc --notriggers \
1941 --excludepath --ignoresize --oldpackage --define \
1942 --eval --pipe --queryformat --repackage --nosuggests \
1943 --nodigest --nosignature' -- $cur ) )
1944 else
1945 _filedir 'rpm'
1946 fi
1947 ;;
1948 -@(e|-erase))
1949 if [[ "$cur" == -* ]]; then
1950 COMPREPLY=( $( compgen -W '--allmatches --noscripts \
1951 --notriggers --nodeps --test --repackage' -- $cur ) )
1952 else
1953 _rpm_installed_packages
1954 fi
1955 ;;
1956 -@(q*|-query))
1957 # check whether we're doing file completion
1958 if [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
1959 if [[ "$cur" == -* ]]; then
1960 COMPREPLY=( $( compgen -W '--scripts --root \
1961 --rcfile --requires --ftpport --ftpproxy \
1962 --httpproxy --httpport --provides --triggers \
1963 --dump --changelog --dbpath \
1964 --last --filesbypkg \
1965 --info --list --state \
1966 --docfiles --configfiles --queryformat \
1967 --conflicts --obsoletes \
1968 --nodigest --nosignature \
1969 --triggerscripts' -- $cur ) )
1970 else
1971 _filedir
1972 fi
1973 elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
1974 _rpm_groups
1975 elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
1976 # uninstalled package completion
1977 if [[ "$cur" == -* ]]; then
1978 COMPREPLY=( $( compgen -W '--scripts --root \
1979 --rcfile --whatprovides --whatrequires \
1980 --requires --triggeredby --ftpport --ftpproxy \
1981 --httpproxy --httpport --provides --triggers \
1982 --dump --changelog --dbpath --filesbypkg \
1983 --define --eval --pipe --showrc --info --list \
1984 --state --docfiles --configfiles --queryformat\
1985 --conflicts --obsoletes --nodigest \
1986 --nosignature' -- $cur ) )
1987 else
1988 _filedir 'rpm'
1989 fi
1990 else
1991 # installed package completion
1992 if [[ "$cur" == -* ]]; then
1993 COMPREPLY=( $( compgen -W '--scripts --root \
1994 --rcfile --whatprovides --whatrequires \
1995 --requires --triggeredby --ftpport --ftpproxy \
1996 --httpproxy --httpport --provides --triggers \
1997 --dump --changelog --dbpath --specfile \
1998 --querybynumber --last --filesbypkg --define \
1999 --eval --pipe --showrc --info --list --state \
2000 --docfiles --configfiles --queryformat \
2001 --conflicts --obsoletes --pkgid --hdrid \
2002 --fileid --tid --nodigest --nosignature \
2003 --triggerscripts' -- $cur ) )
2004 elif [ "${COMP_LINE#* -*([^ -])a}" == "$COMP_LINE" ]; then
2005 _rpm_installed_packages
2006 fi
2007 fi
2008 ;;
2009 -@(K*|-checksig))
2010 if [[ "$cur" == -* ]]; then
2011 COMPREPLY=( $( compgen -W '--nopgp --nogpg --nomd5 \
2012 --nodigest --nosignature' -- $cur ) )
2013 else
2014 _filedir 'rpm'
2015 fi
2016 ;;
2017 -@([Vy]*|-verify))
2018 if [[ "$cur" == -* ]]; then
2019 COMPREPLY=( $( compgen -W '--root --rcfile --dbpath \
2020 --nodeps --nogroup --nolinkto --nomode --nomtime \
2021 --nordev --nouser --nofiles --noscripts --nomd5 \
2022 --querytags --specfile --whatrequires --whatprovides \
2023 --nodigest --nosignature' -- $cur ) )
2024 # check whether we're doing file completion
2025 elif [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
2026 _filedir
2027 elif [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
2028 _rpm_groups
2029 elif [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
2030 _filedir 'rpm'
2031 else
2032 _rpm_installed_packages
2033 fi
2034 ;;
2035 -[bt]*)
2036 if [[ "$cur" == -* ]]; then
2037 COMPREPLY=( $( compgen -W '--short-circuit --timecheck \
2038 --clean --rmsource --rmspec --test --sign --buildroot \
2039 --target -- buildarch --buildos --nobuild --nodeps \
2040 --nodirtokens' -- $cur ) )
2041 elif [[ ${COMP_WORDS[1]} == -b* ]]; then
2042 _filedir 'spec'
2043 else
2044 _filedir '@(tgz|tar.@(gz|bz2))'
2045 fi
2046 ;;
2047 --re@(build|compile))
2048 if [[ "$cur" == -* ]]; then
2049 COMPREPLY=( $( compgen -W '--nodeps --rmsource \
2050 --rmspec --sign --nodirtokens --target' -- $cur ) )
2051 else
2052 _filedir '?(no)src.rpm'
2053 fi
2054 ;;
2055 --tarbuild)
2056 _filedir '@(tgz|tar.@(gz|bz2))'
2057 ;;
2058 --@(re|add)sign)
2059 _filedir 'rpm'
2060 ;;
2061 --set@(perms|gids))
2062 _rpm_installed_packages
2063 ;;
2064 --@(clean|rms@(ource|pec)))
2065 if [[ "$cur" == -* ]]; then
2066 COMPREPLY=( $( compgen -W '--clean --rmsource \
2067 --rmspec' -- $cur ) )
2068 else
2069 _filedir 'spec'
2070 fi
2071 ;;
2072 --@(import|dbpath|root))
2073 if [[ "$cur" == -* ]]; then
2074 COMPREPLY=( $( compgen -W '--import --dbpath --root' \
2075 -- $cur ) )
2076 else
2077 _filedir
2078 fi
2079 ;;
2080 esac
2081
2082 return 0
2083 }
2084 complete -F _rpm $filenames rpm rpmbuild
2085 }
2086
2087 # Debian apt-get(8) completion.
2088 #
2089 have apt-get &&
2090 _apt_get()
2091 {
2092 local cur prev special i
2093
2094 COMPREPLY=()
2095 cur=`_get_cword`
2096 prev=${COMP_WORDS[COMP_CWORD-1]}
2097
2098 for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
2099 if [[ ${COMP_WORDS[i]} == @(install|remove|purge|source|build-dep) ]]; then
2100 special=${COMP_WORDS[i]}
2101 fi
2102 done
2103
2104 if [ -n "$special" ]; then
2105 case $special in
2106 remove|purge)
2107 if [ -f /etc/debian_version ]; then
2108 # Debian system
2109 COMPREPLY=( $( _comp_dpkg_installed_packages \
2110 $cur ) )
2111 else
2112 # assume RPM based
2113 _rpm_installed_packages
2114 fi
2115 return 0
2116 ;;
2117 *)
2118 COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
2119 return 0
2120 ;;
2121
2122 esac
2123 fi
2124
2125 case "$prev" in
2126 -@(c|-config-file))
2127 _filedir
2128 return 0
2129 ;;
2130
2131 -@(t|-target-release|-default-release))
2132 COMPREPLY=( $( apt-cache policy | \
2133 grep "release.o=Debian,a=$cur" | \
2134 sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
2135 return 0
2136 ;;
2137
2138 esac
2139
2140 if [[ "$cur" == -* ]]; then
2141
2142 COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y \
2143 -u -t -b -c -o --download-only --fix-broken \
2144 --help --version --ignore-missing \
2145 --fix-missing --no-download --quiet --simulate \
2146 --just-print --dry-run --recon --no-act --yes \
2147 --assume-yes --show-upgraded --only-source \
2148 --compile --build --ignore-hold \
2149 --target-release --no-upgrade --force-yes \
2150 --print-uris --purge --reinstall \
2151 --list-cleanup --default-release \
2152 --trivial-only --no-remove --diff-only \
2153 --tar-only --config-file --option --auto-remove' -- $cur ) )
2154 else
2155
2156 COMPREPLY=( $( compgen -W 'update upgrade dselect-upgrade \
2157 dist-upgrade install remove purge source \
2158 build-dep check clean autoclean autoremove' \
2159 -- $cur ) )
2160
2161 fi
2162
2163
2164 return 0
2165 } &&
2166 complete -F _apt_get $filenames apt-get
2167
2168 # Debian apt-cache(8) completion.
2169 #
2170 have apt-cache &&
2171 _apt_cache()
2172 {
2173 local cur prev special i
2174
2175 COMPREPLY=()
2176 cur=`_get_cword`
2177 prev=${COMP_WORDS[COMP_CWORD-1]}
2178
2179
2180 if [ "$cur" != show ]; then
2181 for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
2182 if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|policy|rdepends|madison|show?(pkg|src|)) ]]; then
2183 special=${COMP_WORDS[i]}
2184 fi
2185 done
2186 fi
2187
2188
2189 if [ -n "$special" ]; then
2190 case $special in
2191 add)
2192 _filedir
2193 return 0
2194 ;;
2195
2196 *)
2197 COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
2198 return 0
2199 ;;
2200
2201 esac
2202 fi
2203
2204
2205 case "$prev" in
2206 -@(c|p|s|-config-file|-@(pkg|src)-cache))
2207 _filedir
2208 return 0
2209 ;;
2210 search)
2211 if [[ "$cur" != -* ]]; then
2212 return 0
2213 fi
2214 ;;
2215 esac
2216
2217 if [[ "$cur" == -* ]]; then
2218
2219 COMPREPLY=( $( compgen -W '-h -v -p -s -q -i -f -a -g -c \
2220 -o --help --version --pkg-cache --src-cache \
2221 --quiet --important --full --all-versions \
2222 --no-all-versions --generate --no-generate \
2223 --names-only --all-names --recurse \
2224 --config-file --option' -- $cur ) )
2225 else
2226
2227 COMPREPLY=( $( compgen -W 'add gencaches show showpkg showsrc \
2228 stats dump dumpavail unmet search search \
2229 depends rdepends pkgnames dotty xvcg \
2230 policy madison' -- $cur ) )
2231
2232 fi
2233
2234
2235 return 0
2236 } &&
2237 complete -F _apt_cache $filenames apt-cache
2238
2239
2240 # Debian aptitude(1) completion
2241 #
2242 have aptitude && {
2243 have grep-status && {
2244 _comp_dpkg_hold_packages()
2245 {
2246 grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package
2247 }
2248 } || {
2249 _comp_dpkg_hold_packages()
2250 {
2251 grep -B 2 'hold' /var/lib/dpkg/status | grep "Package: $1" \
2252 | cut -d\ -f2
2253 }
2254 }
2255
2256 _aptitude()
2257 {
2258 local cur dashoptions prev special i
2259
2260 COMPREPLY=()
2261 cur=`_get_cword`
2262 prev=${COMP_WORDS[COMP_CWORD-1]}
2263
2264
2265 dashoptions='-S -u -i -h --help --version -s --simulate -d \
2266 --download-only -P --prompt -y --assume-yes -F \
2267 --display-format -O --sort -w --width -f -r -g \
2268 --with-recommends --with-suggests -R -G \
2269 --without-recommends --without-suggests -t \
2270 --target-release -V --show-versions -D --show-deps\
2271 -Z -v --verbose --purge-unused'
2272
2273 for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
2274 if [[ ${COMP_WORDS[i]} == @(install|reinstall|hold|unhold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|forbid-version|purge|remove|changelog|why|why-not|keep|keep-all) ]]; then
2275 special=${COMP_WORDS[i]}
2276 fi
2277 #exclude some mutually exclusive options
2278 [[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i}
2279 [[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u}
2280 done
2281
2282 if [[ -n "$special" ]]; then
2283 case $special in
2284 @(install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|changelog|why|why-not))
2285 COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
2286 return 0
2287 ;;
2288 @(purge|remove|reinstall|forbid-version))
2289 COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
2290 return 0
2291 ;;
2292 unhold)
2293 COMPREPLY=( $( _comp_dpkg_hold_packages $cur ) )
2294 return 0
2295 ;;
2296
2297 esac
2298 fi
2299
2300 case $prev in
2301 # don't complete anything if these options are found
2302 @(autoclean|clean|forget-new|search|upgrade|safe-upgrade|update|keep-all))
2303 return 0
2304 ;;
2305
2306 -S)
2307 _filedir
2308 return 0
2309 ;;
2310
2311 -@(t|-target-release|-default-release))
2312 COMPREPLY=( $( apt-cache policy | \
2313 grep "release.o=Debian,a=$cur" | \
2314 sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) )
2315 return 0
2316 ;;
2317
2318 esac
2319
2320 if [[ "$cur" == -* ]]; then
2321 COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
2322 else
2323 COMPREPLY=( $( compgen -W 'update upgrade safe-upgrade forget-new clean \
2324 autoclean install reinstall remove \
2325 hold unhold purge markauto unmarkauto why why-not \
2326 dist-upgrade full-upgrade download search show \
2327 forbid-version changelog keep-all' -- $cur ) )
2328 fi
2329
2330
2331 return 0
2332 }
2333 complete -F _aptitude $default aptitude
2334 }
2335
2336 # Debian apt-build(1) completion.
2337 #
2338 have apt-build &&
2339 _apt_build()
2340 {
2341 local cur prev special i
2342
2343 COMPREPLY=()
2344 cur=`_get_cword`
2345 prev=${COMP_WORDS[COMP_CWORD-1]}
2346
2347 for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
2348 if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then
2349 special=${COMP_WORDS[i]}
2350 fi
2351 done
2352
2353 if [ -n "$special" ]; then
2354 case $special in
2355 @(install|source|info))
2356 COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )
2357 return 0
2358 ;;
2359 remove)
2360 COMPREPLY=( $( _comp_dpkg_installed_packages \
2361 $cur ) )
2362 return 0
2363 ;;
2364 *)
2365 return 0
2366 ;;
2367 esac
2368 fi
2369
2370 case "$prev" in
2371
2372 --@(patch|build-dir|repository-dir))
2373 _filedir
2374 return 0
2375 ;;
2376
2377 -@(h|-help))
2378 return 0
2379 ;;
2380
2381 esac
2382
2383 if [[ "$cur" == -* ]]; then
2384 COMPREPLY=( $( compgen -W '--help --show-upgraded -u --build-dir \
2385 --repository-dir --build-only \
2386 --build-command --reinstall --rebuild \
2387 --remove-builddep --no-wrapper --purge \
2388 --patch --patch-strip -p --yes -y \
2389 --version -v --no-source' -- $cur ) )
2390
2391 else
2392 COMPREPLY=( $( compgen -W 'update upgrade install remove \
2393 source dist-upgrade world clean info \
2394 clean-build update-repository ' -- $cur ) )
2395 fi
2396
2397
2398 return 0
2399 } &&
2400 complete -F _apt_build $filenames apt-build
2401
2402 # chsh(1) completion
2403 #
2404 _chsh()
2405 {
2406 local cur prev
2407
2408 COMPREPLY=()
2409 cur=`_get_cword`
2410 prev=${COMP_WORDS[COMP_CWORD-1]}
2411
2412 if [ "$prev" = "-s" ]; then
2413 if [ -f /etc/debian_version ]; then
2414 COMPREPLY=( $( </etc/shells ) )
2415 else
2416 COMPREPLY=( $( chsh -l | grep "^$cur" ) )
2417 fi
2418 else
2419 COMPREPLY=( $( compgen -u -- $cur ) )
2420 fi
2421
2422 return 0
2423 }
2424 complete -F _chsh chsh
2425
2426 # chkconfig(8) completion
2427 #
2428 have chkconfig &&
2429 _chkconfig()
2430 {
2431 local cur prev
2432
2433 COMPREPLY=()
2434 cur=`_get_cword`
2435 prev=${COMP_WORDS[COMP_CWORD-1]}
2436
2437 case "$prev" in
2438 @([1-6]|--@(list|add|del)))
2439 _services
2440 return 0
2441 ;;
2442 --level)
2443 COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- $cur ) )
2444 return 0
2445 ;;
2446 esac
2447
2448 if [[ "$cur" == -* ]]; then
2449 COMPREPLY=( $( compgen -W '--list --add --del --level' -- $cur ) )
2450 else
2451 if [ $COMP_CWORD -eq 2 -o $COMP_CWORD -eq 4 ]; then
2452 COMPREPLY=( $( compgen -W 'on off reset' -- $cur ) )
2453 else
2454 _services
2455 fi
2456 fi
2457 } &&
2458 complete -F _chkconfig chkconfig
2459
2460 # This function provides simple user@host completion
2461 #
2462 _user_at_host() {
2463 local cur
2464
2465 COMPREPLY=()
2466 cur=`_get_cword`
2467
2468 if [[ $cur == *@* ]]; then
2469 _known_hosts
2470 else
2471 COMPREPLY=( $( compgen -u -- "$cur" ) )
2472 fi
2473
2474 return 0
2475 }
2476 shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
2477
2478 # This function performs host completion based on ssh's known_hosts files,
2479 # defaulting to standard host completion if they don't exist.
2480 #
2481 _known_hosts()
2482 {
2483 local cur curd ocur user suffix aliases global_kh user_kh hosts i host
2484 local -a kh khd config
2485
2486 COMPREPLY=()
2487 cur=`_get_cword`
2488 ocur=$cur
2489
2490 [ "$1" = -a ] || [ "$2" = -a ] && aliases='yes'
2491 [ "$1" = -c ] || [ "$2" = -c ] && suffix=':'
2492 [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
2493 kh=()
2494
2495 # ssh config files
2496 [ -r /etc/ssh/ssh_config ] &&
2497 config=( "${config[@]}" "/etc/ssh/ssh_config" )
2498 [ -r "${HOME}/.ssh/config" ] &&
2499 config=( "${config[@]}" "${HOME}/.ssh/config" )
2500 [ -r "${HOME}/.ssh2/config" ] &&
2501 config=( "${config[@]}" "${HOME}/.ssh2/config" )
2502
2503 if [ ${#config[@]} -gt 0 ]; then
2504 # expand path (if present) to global known hosts file
2505 global_kh=$( eval echo $( sed -ne 's/^[ \t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) )
2506 # expand path (if present) to user known hosts file
2507 user_kh=$( eval echo $( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) )
2508 fi
2509
2510 # Global known_hosts files
2511 [ -r "$global_kh" ] &&
2512 kh=( "${kh[@]}" "$global_kh" )
2513 [ -r /etc/ssh/ssh_known_hosts ] &&
2514 kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
2515 [ -r /etc/ssh/ssh_known_hosts2 ] &&
2516 kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts2 )
2517 [ -r /etc/known_hosts ] &&
2518 kh=( "${kh[@]}" /etc/known_hosts )
2519 [ -r /etc/known_hosts2 ] &&
2520 kh=( "${kh[@]}" /etc/known_hosts2 )
2521 [ -d /etc/ssh2/knownhosts ] &&
2522 khd=( "${khd[@]}" /etc/ssh2/knownhosts/*pub )
2523
2524 # User known_hosts files
2525 [ -r "$user_kh" ] &&
2526 kh=( "${kh[@]}" "$user_kh" )
2527 [ -r ~/.ssh/known_hosts ] &&
2528 kh=( "${kh[@]}" ~/.ssh/known_hosts )
2529 [ -r ~/.ssh/known_hosts2 ] &&
2530 kh=( "${kh[@]}" ~/.ssh/known_hosts2 )
2531 [ -d ~/.ssh2/hostkeys ] &&
2532 khd=( "${khd[@]}" ~/.ssh2/hostkeys/*pub )
2533
2534 # If we have known_hosts files to use
2535 if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 ]; then
2536 # Escape slashes and dots in paths for awk
2537 cur=${cur//\//\\\/}
2538 cur=${cur//\./\\\.}
2539 curd=$cur
2540
2541 if [[ "$cur" == [0-9]*.* ]]; then
2542 # Digits followed by a dot - just search for that
2543 cur="^$cur.*"
2544 elif [[ "$cur" == [0-9]* ]]; then
2545 # Digits followed by no dot - search for digits followed
2546 # by a dot
2547 cur="^$cur.*\."
2548 elif [ -z "$cur" ]; then
2549 # A blank - search for a dot or an alpha character
2550 cur="[a-z.]"
2551 else
2552 cur="^$cur"
2553 fi
2554
2555 if [ ${#kh[@]} -gt 0 ]; then
2556
2557 # FS needs to look for a comma separated list
2558 COMPREPLY=( $( awk 'BEGIN {FS=","}
2559 /^[^|]/ {for (i=1; i<=2; ++i) { \
2560 gsub(" .*$", "", $i); \
2561 if ($i ~ /'$cur'/) {print $i} \
2562 }}' "${kh[@]}" 2>/dev/null ) )
2563 fi
2564 if [ ${#khd[@]} -gt 0 ]; then
2565 # Needs to look for files called
2566 # .../.ssh2/key_22_<hostname>.pub
2567 # dont fork any processes, because in a cluster environment,
2568 # there can be hundreds of hostkeys
2569 for i in "${khd[@]}" ; do
2570 if [[ "$i" == *key_22_$curd*.pub ]] && [ -r "$i" ] ; then
2571 host=${i/#*key_22_/}
2572 host=${host/%.pub/}
2573 COMPREPLY=( "${COMPREPLY[@]}" $host )
2574 fi
2575 done
2576 fi
2577
2578 # append any available aliases from config files
2579 if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
2580 local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^*?]*\)$/\2/p' "${config[@]}" )
2581 hosts=$( compgen -W "$host_aliases" -- $ocur )
2582 COMPREPLY=( "${COMPREPLY[@]}" $hosts )
2583 fi
2584
2585 # Now add results of normal hostname completion
2586 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -- $ocur ) )
2587
2588 # apply suffix
2589 for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
2590 COMPREPLY[i]=$user${COMPREPLY[i]}$suffix
2591 done
2592 else
2593 # Just do normal hostname completion
2594 COMPREPLY=( $( compgen -A hostname -S "$suffix" -- $cur ) )
2595 fi
2596
2597 return 0
2598 }
2599 complete -F _known_hosts traceroute traceroute6 tracepath tracepath6 \
2600 ping ping6 fping fping6 telnet host nslookup rsh rlogin ftp dig ssh-installkeys mtr
2601
2602 # ssh(1) completion
2603 #
2604 have ssh && {
2605 _ssh()
2606 {
2607 local cur prev
2608 local -a config
2609
2610 COMPREPLY=()
2611 cur=`_get_cword`
2612 prev=${COMP_WORDS[COMP_CWORD-1]}
2613
2614 case "$prev" in
2615 -*c)
2616 COMPREPLY=( $( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \
2617 arcfour cast128-cbc' -- $cur ) )
2618 ;;
2619 -*i)
2620 _filedir
2621 ;;
2622 -*l)
2623 COMPREPLY=( $( compgen -u -- $cur ) )
2624 ;;
2625 *)
2626 _known_hosts -a
2627
2628 [ $COMP_CWORD -eq 1 ] || \
2629 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
2630 esac
2631
2632 return 0
2633 }
2634 shopt -u hostcomplete && complete -F _ssh ssh slogin sftp xhost autossh
2635
2636 # scp(1) completion
2637 #
2638 _scp()
2639 {
2640 local cur userhost path
2641
2642 COMPREPLY=()
2643 cur=`_get_cword`
2644
2645 _expand || return 0
2646
2647 if [[ "$cur" == *:* ]]; then
2648 local IFS=$'\t\n'
2649 # remove backslash escape from :
2650 cur=${cur/\\:/:}
2651 userhost=${cur%%?(\\):*}
2652 path=${cur#*:}
2653 # unescape spaces
2654 path=${path//\\\\\\\\ / }
2655 if [ -z "$path" ]; then
2656 # default to home dir of specified user on remote host
2657 path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
2658 fi
2659 # escape spaces; remove executables, aliases, pipes and sockets;
2660 # add space at end of file names
2661 COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
2662 command ls -aF1d "$path*" 2>/dev/null | \
2663 sed -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\\\\\\\\\&/g" \
2664 -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
2665 return 0
2666 fi
2667
2668 [[ "$cur" == */* ]] || _known_hosts -c -a
2669 local IFS=$'\t\n'
2670 COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \
2671 2>/dev/null | sed \
2672 -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \
2673 -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
2674 return 0
2675 }
2676 complete -F _scp $nospace scp
2677 }
2678
2679 # rsync(1) completion
2680 #
2681 have rsync &&
2682 _rsync()
2683 {
2684 local cur prev shell i userhost path
2685
2686 COMPREPLY=()
2687 cur=`_get_cword`
2688 prev=${COMP_WORDS[COMP_CWORD-1]}
2689
2690 _expand || return 0
2691
2692 case "$prev" in
2693 --@(config|password-file|include-from|exclude-from))
2694 _filedir
2695 return 0
2696 ;;
2697 -@(T|-temp-dir|-compare-dest))
2698 _filedir -d
2699 return 0
2700 ;;
2701 -@(e|-rsh))
2702 COMPREPLY=( $( compgen -W 'rsh ssh' -- $cur ) )
2703 return 0
2704 ;;
2705 esac
2706
2707 case "$cur" in
2708 -*)
2709 COMPREPLY=( $( compgen -W '-v -q -c -a -r -R -b -u -l -L -H \
2710 -p -o -g -D -t -S -n -W -x -B -e -C -I -T -P \
2711 -z -h -4 -6 --verbose --quiet --checksum \
2712 --archive --recursive --relative --backup \
2713 --backup-dir --suffix= --update --links \
2714 --copy-links --copy-unsafe-links --safe-links \
2715 --hard-links --perms --owner --group --devices\
2716 --times --sparse --dry-run --whole-file \
2717 --no-whole-file --one-file-system \
2718 --block-size= --rsh= --rsync-path= \
2719 --cvs-exclude --existing --ignore-existing \
2720 --delete --delete-excluded --delete-after \
2721 --ignore-errors --max-delete= --partial \
2722 --force --numeric-ids --timeout= \
2723 --ignore-times --size-only --modify-window= \
2724 --temp-dir= --compare-dest= --compress \
2725 --exclude= --exclude-from= --include= \
2726 --include-from= --version --daemon --no-detach\
2727 --address= --config= --port= --blocking-io \
2728 --no-blocking-io --stats --progress \
2729 --log-format= --password-file= --bwlimit= \
2730 --write-batch= --read-batch= --help' -- $cur ))
2731 ;;
2732 *:*)
2733 # find which remote shell is used
2734 shell=rsh
2735 for (( i=1; i < COMP_CWORD; i++ )); do
2736 if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then
2737 shell=${COMP_WORDS[i+1]}
2738 break
2739 fi
2740 done
2741 if [[ "$shell" == ssh ]]; then
2742 # remove backslash escape from :
2743 cur=${cur/\\:/:}
2744 userhost=${cur%%?(\\):*}
2745 path=${cur#*:}
2746 # unescape spaces
2747 path=${path//\\\\\\\\ / }
2748 if [ -z "$path" ]; then
2749 # default to home dir of specified
2750 # user on remote host
2751 path=$(ssh -o 'Batchmode yes' \
2752 $userhost pwd 2>/dev/null)
2753 fi
2754 # escape spaces; remove executables, aliases, pipes
2755 # and sockets; add space at end of file names
2756 COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
2757 command ls -aF1d "$path*" 2>/dev/null | \
2758 sed -e 's/ /\\\\\\\ /g' -e 's/[*@|=]$//g' \
2759 -e 's/[^\/]$/& /g' ) )
2760 fi
2761 ;;
2762 *)
2763 _known_hosts -c -a
2764 _filedir
2765 ;;
2766 esac
2767
2768 return 0
2769 } &&
2770 complete -F _rsync $nospace $filenames rsync
2771
2772 # Linux route(8) completion
2773 #
2774 [ $UNAME = Linux ] &&
2775 _route()
2776 {
2777 local cur prev
2778
2779 COMPREPLY=()
2780 cur=`_get_cword`
2781 prev=${COMP_WORDS[COMP_CWORD-1]}
2782
2783 if [ "$prev" = dev ]; then
2784 COMPREPLY=( $( ifconfig -a | sed -ne 's|^\('$cur'[^ ]*\).*$|\1|p' ))
2785 return 0
2786 fi
2787
2788 COMPREPLY=( $( compgen -W 'add del -host -net netmask metric mss \
2789 window irtt reject mod dyn reinstate dev \
2790 default gw' -- $cur ) )
2791
2792 COMPREPLY=( $( echo " ${COMP_WORDS[@]}" | \
2793 (while read -d ' ' i; do
2794 [ "$i" == "" ] && continue
2795 # flatten array with spaces on either side,
2796 # otherwise we cannot grep on word
2797 # boundaries of first and last word
2798 COMPREPLY=" ${COMPREPLY[@]} "
2799 # remove word from list of completions
2800 COMPREPLY=( ${COMPREPLY/ $i / } )
2801 done
2802 echo "${COMPREPLY[@]}")
2803 ) )
2804 return 0
2805 }
2806 [ $UNAME = Linux ] && complete -F _route route
2807
2808 # GNU make(1) completion
2809 #
2810 have make || have gmake || have gnumake || have pmake &&
2811 _make()
2812 {
2813 local file makef makef_dir="." makef_inc cur prev i
2814
2815 COMPREPLY=()
2816 cur=`_get_cword`
2817 prev=${COMP_WORDS[COMP_CWORD-1]}
2818
2819 # --name value style option
2820 case $prev in
2821 -@(f|o|W))
2822 _filedir
2823 return 0
2824 ;;
2825 -@(I|C))
2826 _filedir -d
2827 return 0
2828 ;;
2829 esac
2830
2831 # --name=value style option
2832 if [[ "$cur" == *=* ]]; then
2833 prev=${cur/=*/}
2834 cur=${cur/*=/}
2835 case "$prev" in
2836 --@(file|makefile))
2837 _filedir
2838 return 0
2839 ;;
2840 --@(directory|include-dir))
2841 _filedir -d
2842 return 0
2843 ;;
2844 esac
2845 fi
2846
2847 if [[ "$cur" == -* ]]; then
2848 COMPREPLY=( $( compgen -W '-b -m -B -C -d -e -f -h -i -I\
2849 -j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \
2850 --always-make --directory= --debug \
2851 --environment-overrides --file= --makefile= --help \
2852 --ignore-errors --include-dir= --jobs --load-average \
2853 --max-load --keep-going --just-print --dry-run \
2854 --recon --old-file= --assume-old= --print-data-base \
2855 --question --no-builtin-rules --no-builtin-variables \
2856 --silent --quiet --no-keep-goind --stop --touch \
2857 --version --print-directory --no-print-directory \
2858 --what-if= --new-file= --assume-new= \
2859 --warn-undefined-variables' -- $cur ) )
2860 else
2861 # before we check for makefiles, see if a path was specified
2862 # with -C
2863 for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
2864 if [[ ${COMP_WORDS[i]} == -C ]]; then
2865 # eval for tilde expansion
2866 eval makef_dir=${COMP_WORDS[i+1]}
2867 break
2868 fi
2869 done
2870
2871 # make reads `GNUmakefile', then `makefile', then `Makefile'
2872 if [ -f ${makef_dir}/GNUmakefile ]; then
2873 makef=${makef_dir}/GNUmakefile
2874 elif [ -f ${makef_dir}/makefile ]; then
2875 makef=${makef_dir}/makefile
2876 elif [ -f ${makef_dir}/Makefile ]; then
2877 makef=${makef_dir}/Makefile
2878 else
2879 makef=${makef_dir}/*.mk # local convention
2880 fi
2881
2882 # before we scan for targets, see if a Makefile name was
2883 # specified with -f
2884 for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
2885 if [[ ${COMP_WORDS[i]} == -f ]]; then
2886 # eval for tilde expansion
2887 eval makef=${COMP_WORDS[i+1]}
2888 break
2889 fi
2890 done
2891
2892 [ ! -f $makef ] && return 0
2893
2894 # deal with included Makefiles
2895 makef_inc=$( grep -E '^-?include' $makef | sed -e "s,^.* ,"$makef_dir"/," )
2896
2897 for file in $makef_inc; do
2898 [ -f $file ] && makef="$makef $file"
2899 done
2900
2901 COMPREPLY=( $( awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \
2902 {split($1,A,/ /);for(i in A)print A[i]}' \
2903 $makef 2>/dev/null | command grep "^$cur" ))
2904 fi
2905 } &&
2906 complete -f -F _make $filenames make gmake gnumake pmake
2907
2908 # GNU tar(1) completion
2909 #
2910 _tar()
2911 {
2912 local cur ext regex tar untar
2913
2914 COMPREPLY=()
2915 cur=`_get_cword`
2916
2917 if [ $COMP_CWORD -eq 1 ]; then
2918 COMPREPLY=( $( compgen -W 'c t x u r d A' -- $cur ) )
2919 return 0
2920 fi
2921
2922 case "${COMP_WORDS[1]}" in
2923 ?(-)[cr]*f)
2924 _filedir
2925 return 0
2926 ;;
2927 +([^IZzjy])f)
2928 ext='t@(ar?(.@(Z|gz|bz?(2)))|gz|bz?(2))'
2929 regex='t\(ar\(\.\(Z\|gz\|bz2\?\)\)\?\|gz\|bz2\?\)'
2930 ;;
2931 *[Zz]*f)
2932 ext='t?(ar.)@(gz|Z)'
2933 regex='t\(ar\.\)\?\(gz\|Z\)'
2934 ;;
2935 *[Ijy]*f)
2936 ext='t?(ar.)bz?(2)'
2937 regex='t\(ar\.\)\?bz2\?'
2938 ;;
2939 *)
2940 _filedir
2941 return 0
2942 ;;
2943
2944 esac
2945
2946 if [[ "$COMP_LINE" == *$ext' ' ]]; then
2947 # complete on files in tar file
2948 #
2949 # get name of tar file from command line
2950 tar=$( echo "$COMP_LINE" | \
2951 sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' )
2952 # devise how to untar and list it
2953 untar=t${COMP_WORDS[1]//[^Izjyf]/}
2954
2955 COMPREPLY=( $( compgen -W "$( echo $( tar $untar $tar \
2956 2>/dev/null ) )" -- "$cur" ) )
2957 return 0
2958 fi
2959
2960 # file completion on relevant files
2961 _filedir "$ext"
2962
2963 return 0
2964 }
2965 [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ] && complete -F _tar $dirnames tar ||
2966 complete -F _tar $filenames tar
2967
2968 # jar(1) completion
2969 #
2970 have jar &&
2971 _jar()
2972 {
2973 local cur
2974
2975 COMPREPLY=()
2976 cur=`_get_cword`
2977
2978 if [ $COMP_CWORD = 1 ]; then
2979 COMPREPLY=( $( compgen -W 'c t x u' -- $cur ) )
2980 return 0
2981 fi
2982
2983 case "${COMP_WORDS[1]}" in
2984 *c*f)
2985 _filedir
2986 ;;
2987 *f)
2988 _filedir '?(e|j|w)ar'
2989 ;;
2990 *)
2991 _filedir
2992 ;;
2993 esac
2994 } &&
2995 complete -F _jar $filenames jar
2996
2997 # Linux iptables(8) completion
2998 #
2999 have iptables &&
3000 _iptables()
3001 {
3002 local cur prev table chain
3003
3004 COMPREPLY=()
3005 cur=`_get_cword`
3006 prev=${COMP_WORDS[COMP_CWORD-1]}
3007 chain='s/^Chain \([^ ]\+\).*$/\1/p'
3008
3009 if [[ $COMP_LINE == *-t\ *filter* ]]; then
3010 table="-t filter"
3011 elif [[ $COMP_LINE == *-t\ *nat* ]]; then
3012 table="-t nat"
3013 elif [[ $COMP_LINE == *-t\ *mangle* ]]; then
3014 table="-t mangle"
3015 fi
3016
3017 case "$prev" in
3018 -*[AIDRPFXLZ])
3019 COMPREPLY=( $( compgen -W '`iptables $table -nL | \
3020 sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' -- $cur ) )
3021 ;;
3022 -*t)
3023 COMPREPLY=( $( compgen -W 'nat filter mangle' -- $cur ) )
3024 ;;
3025 -j)
3026 if [ "$table" = "-t filter" -o "$table" = "" ]; then
3027 COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
3028 `iptables $table -nL | sed -ne "$chain" \
3029 -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
3030 $cur ) )
3031 elif [ "$table" = "-t nat" ]; then
3032 COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
3033 MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \
3034 sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
3035 -- $cur ) )
3036 elif [ "$table" = "-t mangle" ]; then
3037 COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
3038 MARK TOS `iptables $table -nL | sed -ne "$chain" \
3039 -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
3040 $cur ) )
3041 fi
3042 ;;
3043 *)
3044 if [[ "$cur" == -* ]]; then
3045 COMPREPLY=( $( compgen -W '-i -o -s -d -p -f -m --append \
3046 --delete --insert --replace --list --flush --zero --new \
3047 --delete-chain --policy --rename-chain --proto --source \
3048 --destination --in-interface --jump --match --numeric \
3049 --out-interface --table --verbose --line-numbers --exact \
3050 --fragment --modprobe= --set-counters --version' -- "$cur") )
3051 fi
3052 ;;
3053 esac
3054
3055 } &&
3056 complete -F _iptables iptables
3057
3058 # tcpdump(8) completion
3059 #
3060 have tcpdump &&
3061 _tcpdump()
3062 {
3063 local cur
3064
3065 COMPREPLY=()
3066 cur=`_get_cword`
3067 prev=${COMP_WORDS[COMP_CWORD-1]}
3068
3069 case "$prev" in
3070 -@(r|w|F))
3071 _filedir
3072 return 0
3073 ;;
3074 -i)
3075 _available_interfaces -a
3076 return 0
3077 ;;
3078 esac
3079
3080
3081 if [[ "$cur" == -* ]]; then
3082 COMPREPLY=( $( compgen -W '-a -d -e -f -l -n -N -O -p \
3083 -q -R -S -t -u -v -x -C -F -i -m -r -s -T -w \
3084 -E' -- $cur ) )
3085 fi
3086
3087 } &&
3088 complete -F _tcpdump tcpdump
3089
3090 # autorpm(8) completion
3091 #
3092 have autorpm &&
3093 _autorpm()
3094 {
3095 local cur
3096
3097 COMPREPLY=()
3098 cur=`_get_cword`
3099
3100 COMPREPLY=( $( compgen -W '--notty --debug --help --version \
3101 auto add fullinfo info help install list \
3102 remove set' -- $cur ) )
3103
3104 } &&
3105 complete -F _autorpm autorpm
3106
3107 # This meta-cd function observes the CDPATH variable, so that cd additionally
3108 # completes on directories under those specified in CDPATH.
3109 #
3110 _cd()
3111 {
3112 local IFS=$'\t\n' cur=`_get_cword` i j k
3113
3114 # try to allow variable completion
3115 if [[ "$cur" == ?(\\)\$* ]]; then
3116 COMPREPLY=( $( compgen -v -P '$' -- "${cur#?(\\)$}" ) )
3117 return 0
3118 fi
3119
3120 # Use standard dir completion if no CDPATH or parameter starts with /,
3121 # ./ or ../
3122 if [ -z "${CDPATH:-}" ] || [[ "$cur" == ?(.)?(.)/* ]]; then
3123 _filedir -d
3124 return 0
3125 fi
3126
3127 local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
3128 local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y)
3129
3130 # we have a CDPATH, so loop on its contents
3131 for i in ${CDPATH//:/$'\t'}; do
3132 # create an array of matched subdirs
3133 k="${#COMPREPLY[@]}"
3134 for j in $( compgen -d $i/$cur ); do
3135 if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
3136 j="${j}/"
3137 fi
3138 COMPREPLY[k++]=${j#$i/}
3139 done
3140 done
3141
3142 _filedir -d
3143
3144 if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
3145 i=${COMPREPLY[0]}
3146 if [ "$i" == "$cur" ] && [[ $i != "*/" ]]; then
3147 COMPREPLY[0]="${i}/"
3148 fi
3149 fi
3150
3151 return 0
3152 }
3153 if shopt -q cdable_vars; then
3154 complete -v -F _cd $nospace $filenames cd
3155 else
3156 complete -F _cd $nospace $filenames cd
3157 fi
3158
3159 _remove_comp_word()
3160 {
3161 if [[ COMP_CWORD -eq 0 ]]; then
3162 return
3163 elif [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
3164 local old_cw0="${COMP_WORDS[0]}"
3165 local new_cw0="${COMP_WORDS[1]}"
3166 local old_length="${#COMP_LINE}"
3167 COMP_LINE=${COMP_LINE#${old_cw0}}
3168 local head=${COMP_LINE:0:${#new_cw0}}
3169 local i=1
3170 while [[ $head != $new_cw0 ]]; do
3171 COMP_LINE=${COMP_LINE:1}
3172 head=${COMP_LINE:0:${#new_cw0}}
3173 if (( ++i > 10 )); then
3174 break
3175 fi
3176 done
3177 local new_length="${#COMP_LINE}"
3178 COMP_POINT=$(( COMP_POINT + new_length - old_length))
3179
3180 COMP_CWORD=$(( COMP_CWORD - 1 ))
3181 for (( i=0; i < ${#COMP_WORDS[@]} - 1; ++i )); do
3182 COMP_WORDS[i]="${COMP_WORDS[i+1]}"
3183 done
3184 unset COMP_WORDS[${#COMP_WORDS[@]}-1]
3185 else
3186 return
3187 fi
3188 }
3189
3190 # A meta-command completion function for commands like sudo(8), which need to
3191 # first complete on a command, then complete according to that command's own
3192 # completion definition - currently not quite foolproof (e.g. mount and umount
3193 # don't work properly), but still quite useful.
3194 #
3195 _command()
3196 {
3197 local cur func cline cspec noglob cmd done i \
3198 _COMMAND_FUNC _COMMAND_FUNC_ARGS
3199
3200 _remove_comp_word
3201 COMPREPLY=()
3202 cur=`_get_cword`
3203 # If the the first arguments following our meta-command-invoker are
3204 # switches, get rid of them. Most definitely not foolproof.
3205 done=
3206 while [ -z $done ] ; do
3207 cmd=${COMP_WORDS[0]}
3208 if [[ "$cmd" == -* ]] && [ $COMP_CWORD -ge 1 ]; then
3209 _remove_comp_word
3210 elif [[ "$cmd" == -* ]] && [[ $COMP_CWORD -eq 0 ]]; then
3211 return
3212 else
3213 done=1
3214 fi
3215 done
3216
3217 if [ $COMP_CWORD -eq 0 ]; then
3218 COMPREPLY=( $( compgen -c -- $cur ) )
3219 elif complete -p $cmd &>/dev/null; then
3220 cspec=$( complete -p $cmd )
3221 if [ "${cspec#* -F }" != "$cspec" ]; then
3222 # COMP_CWORD and COMP_WORDS() are not read-only,
3223 # so we can set them before handing off to regular
3224 # completion routine
3225
3226 # get function name
3227 func=${cspec#*-F }
3228 func=${func%% *}
3229
3230 if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
3231 $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}"
3232 else
3233 $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}"
3234 fi
3235
3236 # remove any \: generated by a command that doesn't
3237 # default to filenames or dirnames (e.g. sudo chown)
3238 # FIXME: I'm pretty sure this does not work!
3239 if [ "${cspec#*-o }" != "$cspec" ]; then
3240 cspec=${cspec#*-o }
3241 cspec=${cspec%% *}
3242 if [[ "$cspec" != @(dir|file)names ]]; then
3243 COMPREPLY=("${COMPREPLY[@]//\\\\:/:}")
3244 fi
3245 fi
3246 elif [ -n "$cspec" ]; then
3247 cspec=${cspec#complete};
3248 cspec=${cspec%%$cmd};
3249 COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) );
3250 fi
3251 fi
3252
3253 [ ${#COMPREPLY[@]} -eq 0 ] && _filedir
3254 }
3255 complete -F _command $filenames nohup exec nice eval strace time ltrace then \
3256 else do vsound command xargs
3257
3258 _root_command()
3259 {
3260 PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin _command $1 $2 $3
3261 }
3262 complete -F _root_command $filenames sudo fakeroot really
3263
3264 # ant(1) completion
3265 #
3266 have ant && {
3267 _ant()
3268 {
3269 local cur prev buildfile i
3270
3271 COMPREPLY=()
3272 cur=`_get_cword`
3273 prev=${COMP_WORDS[COMP_CWORD-1]}
3274
3275 case "$prev" in
3276 -buildfile|-f)
3277 _filedir 'xml'
3278 return 0
3279 ;;
3280 -logfile)
3281 _filedir
3282 return 0
3283 ;;
3284 esac
3285
3286 if [[ "$cur" == -* ]]; then
3287 # relevant options completion
3288 COMPREPLY=( $( compgen -W '-help -projecthelp -version -quiet \
3289 -verbose -debug -emacs -logfile -logger \
3290 -listener -buildfile -f -D -find' -- $cur ) )
3291 else
3292 # available targets completion
3293 # find which buildfile to use
3294 buildfile=build.xml
3295 for (( i=1; i < COMP_CWORD; i++ )); do
3296 if [[ "${COMP_WORDS[i]}" == -buildfile ]]; then
3297 buildfile=${COMP_WORDS[i+1]}
3298 break
3299 fi
3300 done
3301 [ ! -f $buildfile ] && return 0
3302
3303 # parse buildfile for targets
3304 COMPREPLY=( $( awk -F'"' '/<target name="/ {print $2}' \
3305 $buildfile | grep "^$cur" )
3306 $( awk -F"'" "/<target name='/ "'{print $2}' \
3307 $buildfile | grep "^$cur" )
3308 $( awk -F'"' '/<target [^n]/ {if ($1 ~ /name=/) { print $2 } else if ($3 ~ /name=/) {print $4} else if ($5 ~ /name=/) {print $6}}' \
3309 $buildfile | grep "^$cur" ) )
3310 fi
3311 }
3312 have complete-ant-cmd.pl && \
3313 complete -C complete-ant-cmd.pl -F _ant $filenames ant || \
3314 complete -F _ant $filenames ant
3315 }
3316
3317 have nslookup &&
3318 _nslookup()
3319 {
3320 local cur
3321
3322 COMPREPLY=()
3323 cur=${COMP_WORDS[COMP_CWORD]#-}
3324
3325 COMPREPLY=( $( compgen -P '-' -W 'all class= debug d2 domain= \
3326 srchlist= defname search port= querytype= \
3327 type= recurse retry root timeout vc \
3328 ignoretc' -- $cur ) )
3329 } &&
3330 complete -F _nslookup nslookup
3331
3332 # mysqladmin(1) completion
3333 #
3334 have mysqladmin &&
3335 _mysqladmin()
3336 {
3337 local cur prev
3338
3339 COMPREPLY=()
3340 cur=`_get_cword`
3341 prev=${COMP_WORDS[COMP_CWORD-1]}
3342
3343 case "$prev" in
3344 -u)
3345 COMPREPLY=( $( compgen -u -- $cur ) )
3346 return 0
3347 ;;
3348 *)
3349 ;;
3350 esac
3351
3352 COMPREPLY=( $( compgen -W '-# -f -? -C -h -p -P -i -r -E -s -S -t -u \
3353 -v -V -w' -- $cur ) )
3354
3355 COMPREPLY=( "${COMPREPLY[@]}" \
3356 $( compgen -W 'create drop extended-status flush-hosts \
3357 flush-logs flush-status flush-tables \
3358 flush-threads flush-privileges kill \
3359 password ping processlist reload refresh \
3360 shutdown status variables version' \
3361 -- $cur ) )
3362 } &&
3363 complete -F _mysqladmin mysqladmin
3364
3365 # gzip(1) completion
3366 #
3367 have gzip &&
3368 _gzip()
3369 {
3370 local cur prev xspec IFS=$'\t\n'
3371
3372 COMPREPLY=()
3373 cur=`_get_cword`
3374 prev=${COMP_WORDS[COMP_CWORD-1]}
3375
3376 if [[ "$cur" == -* ]]; then
3377 COMPREPLY=( $( compgen -W '-c -d -f \
3378 -h -l -L -n -N -q -r -S -t -v -V \
3379 -1 -2 -3 -4 -5 -6 -7 -8 -9 \
3380 --stdout --decompress --force --help --list \
3381 --license --no-name --name --quiet --recursive \
3382 --suffix --test --verbose --version --fast \
3383 --best' -- $cur ) )
3384 return 0
3385 fi
3386
3387 xspec="*.?(t)gz"
3388 if [[ "$prev" == --* ]]; then
3389 [[ "$prev" == --decompress || \
3390 "$prev" == --list || \
3391 "$prev" == --test ]] && xspec="!"$xspec
3392 [[ "$prev" == --force ]] && xspec=
3393 elif [[ "$prev" == -* ]]; then
3394 [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
3395 [[ "$prev" == -*f* ]] && xspec=
3396 elif [ "$prev" = '>' ]; then
3397 xspec=
3398 elif [ "$prev" = '<' ]; then
3399 xspec=
3400 fi
3401
3402 _expand || return 0
3403
3404 COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
3405 $( compgen -d -- $cur ) )
3406 } &&
3407 complete -F _gzip $filenames gzip
3408
3409 # bzip2(1) completion
3410 #
3411 have bzip2 &&
3412 _bzip2()
3413 {
3414 local cur prev xspec IFS=$'\t\n'
3415
3416 COMPREPLY=()
3417 cur=`_get_cword`
3418 prev=${COMP_WORDS[COMP_CWORD-1]}
3419
3420 if [[ "$cur" == -* ]]; then
3421 COMPREPLY=( $( compgen -W '-c -d -f -h -k -L -q -s \
3422 -t -v -V -z -1 -2 -3 -4 -5 -6 -7 -8 -9 \
3423 --help --decompress --compress --keep --force \
3424 --test --stdout --quiet --verbose --license \
3425 --version --small --fast --best' -- $cur ) )
3426 return 0
3427 fi
3428
3429 xspec="*.bz2"
3430 if [[ "$prev" == --* ]]; then
3431 [[ "$prev" == --decompress || \
3432 "$prev" == --list || \
3433 "$prev" == --test ]] && xspec="!"$xspec
3434 [[ "$prev" == --compress ]] && xspec=
3435 elif [[ "$prev" == -* ]]; then
3436 [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec
3437 [[ "$prev" == -*z* ]] && xspec=
3438 fi
3439
3440 _expand || return 0
3441
3442 COMPREPLY=( $( compgen -f -X "$xspec" -- $cur ) \
3443 $( compgen -d -- $cur ) )
3444 } &&
3445 complete -F _bzip2 $filenames bzip2
3446
3447 # openssl(1) completion
3448 #
3449 have openssl && {
3450 _openssl_sections()
3451 {
3452 local config
3453
3454 config=/etc/ssl/openssl.cnf
3455 [ ! -f $config ] && config=/usr/share/ssl/openssl.cnf
3456 for (( i=2; i < COMP_CWORD; i++ )); do
3457 if [[ "${COMP_WORDS[i]}" == -config ]]; then
3458 config=${COMP_WORDS[i+1]}
3459 break
3460 fi
3461 done
3462 [ ! -f $config ] && return 0
3463
3464 COMPREPLY=( $( awk '/\[.*\]/ {print $2} ' $config | grep "^$cur" ) )
3465 }
3466
3467 _openssl()
3468 {
3469 local cur prev
3470
3471 COMPREPLY=()
3472 cur=`_get_cword`
3473
3474 if [ $COMP_CWORD -eq 1 ]; then
3475 COMPREPLY=( $( compgen -W 'asn1parse ca ciphers crl crl2pkcs7 \
3476 dgst dh dhparam dsa dsaparam enc errstr gendh gendsa \
3477 genrsa nseq passwd pkcs12 pkcs7 pkcs8 rand req rsa \
3478 rsautl s_client s_server s_time sess_id smime speed \
3479 spkac verify version x509 md2 md4 md5 mdc2 rmd160 sha \
3480 sha1 base64 bf bf-cbc bf-cfb bf-ecb bf-ofb cast \
3481 cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb des \
3482 des-cbc des-cfb des-ecb des-ede des-ede-cbc \
3483 des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc \
3484 des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \
3485 rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb \
3486 rc4 rc4-40' -- $cur ) )
3487 else
3488 prev=${COMP_WORDS[COMP_CWORD-1]}
3489 case ${COMP_WORDS[1]} in
3490 asn1parse)
3491 case $prev in
3492 -inform)
3493 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3494 return 0
3495 ;;
3496 -@(in|out|oid))
3497 _filedir
3498 return 0
3499 ;;
3500 esac
3501
3502 if [[ "$cur" == -* ]]; then
3503 COMPREPLY=( $( compgen -W '-inform -in -out -noout -offset \
3504 -length -i -oid -strparse' -- $cur ) )
3505 fi
3506 ;;
3507 ca)
3508 case $prev in
3509 -@(config|revoke|cert|in|out|spkac|ss_cert))
3510 _filedir
3511 return 0
3512 ;;
3513 -outdir)
3514 _filedir -d
3515 return 0
3516 ;;
3517 -@(name|crlexts|extensions))
3518 _openssl_sections
3519 return 0
3520 ;;
3521 esac
3522
3523 if [[ "$cur" == -* ]]; then
3524 COMPREPLY=( $( compgen -W '-verbose -config -name \
3525 -gencrl -revoke -crldays -crlhours -crlexts \
3526 -startdate -enddate -days -md -policy -keyfile \
3527 -key -passin -cert -in -out -notext -outdir \
3528 -infiles -spkac -ss_cert -preserveDN -batch \
3529 -msie_hack -extensions' -- $cur ) )
3530 fi
3531 ;;
3532 ciphers)
3533 if [[ "$cur" == -* ]]; then
3534 COMPREPLY=( $( compgen -W '-v -ssl2 -ssl3 -tls1' -- $cur ) )
3535 fi
3536 ;;
3537 crl)
3538 case $prev in
3539 -@(in|out)form)
3540 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3541 return 0
3542 ;;
3543 -@(in|out|CAfile))
3544 _filedir
3545 return 0
3546 ;;
3547 -CAPath)
3548 _filedir -d
3549 return 0
3550 ;;
3551 esac
3552
3553 if [[ "$cur" == -* ]]; then
3554 COMPREPLY=( $( compgen -W '-inform -outform -text -in -out -noout \
3555 -hash -issuer -lastupdate -nextupdate -CAfile -CApath' -- $cur ) )
3556 fi
3557 ;;
3558 crl2pkcs7)
3559 case $prev in
3560 -@(in|out)form)
3561 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3562 return 0
3563 ;;
3564 -@(in|out))
3565 _filedir
3566 return 0
3567 ;;
3568 esac
3569
3570 if [[ "$cur" == -* ]]; then
3571 COMPREPLY=( $( compgen -W '-inform -outform -in -out -print_certs' -- $cur ) )
3572 fi
3573 ;;
3574 dgst)
3575 case $prev in
3576 -@(out|sign|verify|prvrify|signature))
3577 _filedir
3578 return 0
3579 ;;
3580 esac
3581
3582 if [[ "$cur" == -* ]]; then
3583 COMPREPLY=( $( compgen -W '-md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 \
3584 -c -d -hex -binary -out -sign -verify -prverify -signature' -- $cur ) )
3585 else
3586 _filedir
3587 fi
3588 ;;
3589 dsa)
3590 case $prev in
3591 -@(in|out)form)
3592 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3593 return 0
3594 ;;
3595 -@(in|out))
3596 _filedir
3597 return 0
3598 ;;
3599 esac
3600
3601 if [[ "$cur" == -* ]]; then
3602 COMPREPLY=( $( compgen -W '-inform -outform -in -passin -out -passout -des -des3 -idea -text -noout \
3603 -modulus -pubin -pubout' -- $cur ) )
3604 fi
3605 ;;
3606 dsaparam)
3607 case $prev in
3608 -@(in|out)form)
3609 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3610 return 0
3611 ;;
3612 -@(in|out|rand))
3613 _filedir
3614 return 0
3615 ;;
3616 esac
3617
3618 if [[ "$cur" == -* ]]; then
3619 COMPREPLY=( $( compgen -W '-inform -outform -in -out -noout \
3620 -text -C -rand -genkey' -- $cur ) )
3621 fi
3622 ;;
3623 enc)
3624 case $prev in
3625 -@(in|out|kfile))
3626 _filedir
3627 return 0
3628 ;;
3629 esac
3630
3631 if [[ "$cur" == -* ]]; then
3632 COMPREPLY=( $( compgen -W '-ciphername -in -out -pass \
3633 -e -d -a -A -k -kfile -S -K -iv -p -P -bufsize -debug' -- $cur ) )
3634 fi
3635 ;;
3636 dhparam)
3637 case $prev in
3638 -@(in|out)form)
3639 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3640 return 0
3641 ;;
3642 -@(in|out|rand))
3643 _filedir
3644 return 0
3645 ;;
3646 esac
3647
3648 if [[ "$cur" == -* ]]; then
3649 COMPREPLY=( $( compgen -W '-inform -outform -in -out -dsaparam -noout \
3650 -text -C -2 -5 -rand' -- $cur ) )
3651 fi
3652 ;;
3653 gendsa)
3654 case $prev in
3655 -@(out|rand))
3656 _filedir
3657 return 0
3658 ;;
3659 esac
3660
3661 if [[ "$cur" == -* ]]; then
3662 COMPREPLY=( $( compgen -W '-out -des -des3 -idea -rand' -- $cur ) )
3663 else
3664 _filedir
3665 fi
3666 ;;
3667 genrsa)
3668 case $prev in
3669 -@(out|rand))
3670 _filedir
3671 return 0
3672 ;;
3673 esac
3674
3675 if [[ "$cur" == -* ]]; then
3676 COMPREPLY=( $( compgen -W '-out -passout -des -des3 -idea -f4 -3 -rand' -- $cur ) )
3677 fi
3678 ;;
3679 pkcs7)
3680 case $prev in
3681 -@(in|out)form)
3682 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3683 return 0
3684 ;;
3685 -@(in|out))
3686 _filedir
3687 return 0
3688 ;;
3689 esac
3690
3691 if [[ "$cur" == -* ]]; then
3692 COMPREPLY=( $( compgen -W '-inform -outform -in -out -print_certs -text -noout' -- $cur ) )
3693 fi
3694 ;;
3695 rand)
3696 case $prev in
3697 -@(out|rand))
3698 _filedir
3699 return 0
3700 ;;
3701 esac
3702
3703 if [[ "$cur" == -* ]]; then
3704 COMPREPLY=( $( compgen -W '-out -rand -base64' -- $cur ) )
3705 fi
3706 ;;
3707 req)
3708 case "$prev" in
3709 -@(in|out|key)form)
3710 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3711 return 0
3712 ;;
3713
3714 -@(in|out|rand|key|keyout|config))
3715 _filedir
3716 return 0
3717 ;;
3718 -extensions)
3719 _openssl_sections
3720 return 0
3721 ;;
3722 esac
3723
3724 if [[ "$cur" == -* ]]; then
3725 COMPREPLY=( $( compgen -W '-inform -outform -in \
3726 -passin -out -passout -text -noout -verify \
3727 -modulus -new -rand -newkey -newkey -nodes \
3728 -key -keyform -keyout -md5 -sha1 -md2 -mdc2 \
3729 -config -x509 -days -asn1-kludge -newhdr \
3730 -extensions -reqexts section' -- $cur ) )
3731 fi
3732 ;;
3733 rsa)
3734 case $prev in
3735 -@(in|out)form)
3736 COMPREPLY=( $( compgen -W 'DER NET PEM' -- $cur ) )
3737 return 0
3738 ;;
3739 -@(in|out))
3740 _filedir
3741 return 0
3742 ;;
3743 esac
3744
3745 if [[ "$cur" == -* ]]; then
3746 COMPREPLY=( $( compgen -W '-inform -outform -in -passin -out -passout \
3747 -sgckey -des -des3 -idea -text -noout -modulus -check -pubin \
3748 -pubout -engine' -- $cur ) )
3749 fi
3750 ;;
3751 rsautl)
3752 case $prev in
3753 -@(in|out|inkey))
3754 _filedir
3755 return 0
3756 ;;
3757 esac
3758
3759 if [[ "$cur" == -* ]]; then
3760 COMPREPLY=( $( compgen -W '-in -out -inkey -pubin -certin -sign -verify \
3761 -encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse' -- $cur ) )
3762 fi
3763 ;;
3764 s_client)
3765 case $prev in
3766 -connect)
3767 _known_hosts
3768 return 0
3769 ;;
3770 -@(cert|key|CAfile|rand))
3771 _filedir
3772 return 0
3773 ;;
3774 -CApath)
3775 _filedir -d
3776 return 0
3777 ;;
3778 esac
3779
3780 if [[ "$cur" == -* ]]; then
3781 COMPREPLY=( $( compgen -W '-connect -verify -cert -key -CApath -CAfile \
3782 -reconnect -pause -showcerts -debug -msg -nbio_test -state -nbio \
3783 -crlf -ign_eof -quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 \
3784 -bugs -cipher -starttls -engine -rand' -- $cur ) )
3785 fi
3786 ;;
3787 s_server)
3788 case $prev in
3789 -@(cert|key|dcert|dkey|dhparam|CAfile|rand))
3790 _filedir
3791 return 0
3792 ;;
3793 -CApath)
3794 _filedir -d
3795 return 0
3796 ;;
3797 esac
3798
3799 if [[ "$cur" == -* ]]; then
3800 COMPREPLY=( $( compgen -W '-accept -context -verify -Verify -cert -key \
3801 -dcert -dkey -dhparam -nbio -nbio_test -crlf -debug -msg -state -CApath \
3802 -CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2 -ssl3 -tls1 -no_ssl2 \
3803 -no_ssl3 -no_tls1 -no_dhe -bugs -hack -www -WWW -HTTP -engine -id_prefix \
3804 -rand' -- $cur ) )
3805 fi
3806 ;;
3807 s_time)
3808 case $prev in
3809 -connect)
3810 _known_hosts
3811 return 0
3812 ;;
3813 -@(cert|key|CAfile))
3814 _filedir
3815 return 0
3816 ;;
3817 -CApath)
3818 _filedir -d
3819 return 0
3820 ;;
3821 esac
3822
3823 if [[ "$cur" == -* ]]; then
3824 COMPREPLY=( $( compgen -W '-connect -www -cert -key -CApath -CAfile -reuse \
3825 -new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher' -- $cur ) )
3826 fi
3827 ;;
3828
3829 sess_id)
3830 case $prev in
3831 -@(in|out)form)
3832 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3833 return 0
3834 ;;
3835 -@(in|out))
3836 _filedir
3837 return 0
3838 ;;
3839 esac
3840
3841
3842 if [[ "$cur" == -* ]]; then
3843 COMPREPLY=( $( compgen -W '-inform -outform -in -out -text -noout \
3844 -context ID' -- $cur ) )
3845 fi
3846 ;;
3847 smime)
3848 case $prev in
3849 -@(in|out)form)
3850 COMPREPLY=( $( compgen -W 'SMIME DER PEM' -- $cur ) )
3851 return 0
3852 ;;
3853 -@(in|out|certfile|signer|recip|inkey|content|rand))
3854 _filedir
3855 return 0
3856 ;;
3857 esac
3858
3859 if [[ "$cur" == -* ]]; then
3860 COMPREPLY=( $( compgen -W '-encrypt -decrypt -sign -verify -pk7out -des -des3 \
3861 -rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 -in -certfile -signer \
3862 -recip -inform -passin -inkey -out -outform -content -to -from -subject \
3863 -text -rand' -- $cur ) )
3864 else
3865 _filedir
3866 fi
3867 ;;
3868 speed)
3869 if [[ "$cur" == -* ]]; then
3870 COMPREPLY=( $( compgen -W '-engine' -- $cur ) )
3871 else
3872 COMPREPLY=( $( compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 idea-cbc \
3873 rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 rsa512 rsa1024 rsa2048 \
3874 rsa4096 dsa512 dsa1024 dsa2048 idea rc2 des rsa blowfish' -- $cur ) )
3875 fi
3876 ;;
3877 verify)
3878 case $prev in
3879 -@(CAfile|untrusted))
3880 _filedir
3881 return 0
3882 ;;
3883 -CApath)
3884 _filedir -d
3885 return 0
3886 ;;
3887 esac
3888
3889 if [[ "$cur" == -* ]]; then
3890 COMPREPLY=( $( compgen -W '-CApath -CAfile -purpose -untrusted -help -issuer_checks \
3891 -verbose -certificates' -- $cur ) )
3892 else
3893 _filedir
3894 fi
3895 ;;
3896 x509)
3897 case "$prev" in
3898 -@(in|out|CA|CAkey|CAserial|extfile))
3899 _filedir
3900 return 0
3901 ;;
3902 -@(in|out)form)
3903 COMPREPLY=( $( compgen -W 'DER PEM NET' -- $cur ) )
3904 return 0
3905 ;;
3906 -@(key|CA|CAkey)form)
3907 COMPREPLY=( $( compgen -W 'DER PEM' -- $cur ) )
3908 return 0
3909 ;;
3910 -extensions)
3911 _openssl_sections
3912 return 0
3913 ;;
3914 esac
3915
3916 if [[ "$cur" == -* ]]; then
3917 COMPREPLY=( $( compgen -W '-inform -outform \
3918 -keyform -CAform -CAkeyform -in -out \
3919 -serial -hash -subject -issuer -nameopt \
3920 -email -startdate -enddate -purpose \
3921 -dates -modulus -fingerprint -alias \
3922 -noout -trustout -clrtrust -clrreject \
3923 -addtrust -addreject -setalias -days \
3924 -set_serial -signkey -x509toreq -req \
3925 -CA -CAkey -CAcreateserial -CAserial \
3926 -text -C -md2 -md5 -sha1 -mdc2 -clrext \
3927 -extfile -extensions -engine' -- $cur ) )
3928 fi
3929 ;;
3930 @(md5|md4|md2|sha1|sha|mdc2|ripemd160))
3931 if [[ "$cur" == -* ]]; then
3932 COMPREPLY=( $( compgen -W '-c -d' -- $cur ) )
3933 else
3934 _filedir
3935 fi
3936 ;;
3937 esac
3938 fi
3939
3940 return 0
3941 }
3942 complete -F _openssl $default openssl
3943 }
3944
3945 # screen(1) completion
3946 #
3947 have screen &&
3948 _screen()
3949 {
3950 local cur prev preprev
3951
3952 COMPREPLY=()
3953 cur=`_get_cword`
3954 prev=${COMP_WORDS[COMP_CWORD-1]}
3955
3956 [ "$COMP_CWORD" -ge 2 ] && preprev=${COMP_WORDS[COMP_CWORD-2]}
3957
3958 if [ "$preprev" = "-d" -o "$preprev" = "-D" -a "$prev" = "-r" -o \
3959 "$prev" = "-R" ]; then
3960 # list all
3961 COMPREPLY=( $( command screen -ls | \
3962 sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*$|\1|p' ) )
3963 else
3964 case "$prev" in
3965 -[rR])
3966 # list detached
3967 COMPREPLY=( $( command screen -ls | \
3968 sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*Detached.*$|\1|p' ) )
3969 ;;
3970 -[dDx])
3971 # list attached
3972 COMPREPLY=( $( command screen -ls | \
3973 sed -ne 's|^['$'\t'']\+\('$cur'[0-9]\+\.[^'$'\t'']\+\).*Attached.*$|\1|p' ) )
3974 ;;
3975 -s)
3976 # shells
3977 COMPREPLY=( $( grep ^${cur:-[^#]} /etc/shells ) )
3978 ;;
3979 *)
3980 ;;
3981 esac
3982 fi
3983
3984 return 0
3985 } &&
3986 complete -F _screen $default screen
3987
3988 # lftp(1) bookmark completion
3989 #
3990 have lftp &&
3991 _lftp()
3992 {
3993 local cur
3994
3995 COMPREPLY=()
3996 cur=`_get_cword`
3997
3998 if [ $COMP_CWORD -eq 1 ] && [ -f ~/.lftp/bookmarks ]; then
3999 COMPREPLY=( $( compgen -W '$( sed -ne "s/^\(.*\)'$'\t''.*$/\1/p" \
4000 ~/.lftp/bookmarks )' -- $cur ) )
4001 fi
4002
4003 return 0
4004 } &&
4005 complete -F _lftp $default lftp
4006
4007 # ncftp(1) bookmark completion
4008 #
4009 have ncftp &&
4010 _ncftp()
4011 {
4012 local cur
4013
4014 COMPREPLY=()
4015 cur=`_get_cword`
4016
4017 if [ $COMP_CWORD -eq 1 ] && [ -f ~/.ncftp/bookmarks ]; then
4018 COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
4019 ~/.ncftp/bookmarks )' -- $cur ) )
4020 fi
4021
4022 return 0
4023 } &&
4024 complete -F _ncftp $default ncftp
4025
4026 # gdb(1) completion
4027 #
4028 have gdb &&
4029 _gdb()
4030 {
4031 local cur prev
4032
4033 COMPREPLY=()
4034 cur=`_get_cword`
4035 prev=${COMP_WORDS[COMP_CWORD-1]}
4036
4037 if [ $COMP_CWORD -eq 1 ]; then
4038 COMPREPLY=( $( compgen -c -- $cur ) )
4039 elif [ $COMP_CWORD -eq 2 ]; then
4040 prev=${prev##*/}
4041 COMPREPLY=( $( compgen -fW "$( command ps axo comm,pid | \
4042 awk '{if ($1 ~ /^'"$prev"'/) print $2}' ) )" \
4043 -- "$cur" ) )
4044 fi
4045 } &&
4046 complete -F _gdb $filenames gdb
4047
4048 # Postgresql completion
4049 #
4050 have psql && {
4051 _pg_databases()
4052 {
4053 return
4054 COMPREPLY=( $( psql -l 2>/dev/null | \
4055 sed -e '1,/^-/d' -e '/^(/,$d' | \
4056 awk '{print $1}' | grep "^$cur" ) )
4057 }
4058
4059 _pg_users()
4060 {
4061 #COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
4062 # grep "^ $cur" ) )
4063 #[ ${#COMPREPLY[@]} -eq 0 ] &&
4064 COMPREPLY=( $( compgen -u -- $cur ) )
4065 }
4066
4067 # createdb(1) completion
4068 #
4069 _createdb()
4070 {
4071 local cur prev
4072
4073 COMPREPLY=()
4074 cur=`_get_cword`
4075 prev=${COMP_WORDS[COMP_CWORD-1]}
4076
4077 case "$prev" in
4078 -@(h|-host=))
4079 _known_hosts
4080 return 0
4081 ;;
4082 -@(U|-username=))
4083 _pg_users
4084 return 0
4085 ;;
4086 esac
4087
4088 if [[ "$cur" == -* ]]; then
4089 COMPREPLY=( $( compgen -W '-D -T -E -h -p -U -W -e -q \
4090 --location= --template= --encoding= --host= --port= \
4091 --username= --password --echo --quiet --help' -- $cur ))
4092 else
4093 _pg_databases
4094 fi
4095 }
4096 complete -F _createdb $default createdb
4097
4098 # dropdb(1) completion
4099 #
4100 _dropdb()
4101 {
4102 local cur prev
4103
4104 COMPREPLY=()
4105 cur=`_get_cword`
4106 prev=${COMP_WORDS[COMP_CWORD-1]}
4107
4108 case "$prev" in
4109 -@(h|-host=))
4110 _known_hosts
4111 return 0
4112 ;;
4113 -@(U|-username=))
4114 _pg_users
4115 return 0
4116 ;;
4117 esac
4118
4119 if [[ "$cur" == -* ]]; then
4120 COMPREPLY=( $( compgen -W '-h -p -U -W -e -q \
4121 --host= --port= --username= --password \
4122 --interactive --echo --quiet --help' -- $cur ) )
4123 else
4124 _pg_databases
4125 fi
4126 }
4127 complete -F _dropdb $default dropdb
4128
4129 # psql(1) completion
4130 #
4131 _psql()
4132 {
4133 local cur prev
4134
4135 COMPREPLY=()
4136 cur=`_get_cword`
4137 prev=${COMP_WORDS[COMP_CWORD-1]}
4138
4139 case "$prev" in
4140 -h|--host)
4141 _known_hosts
4142 return 0
4143 ;;
4144 -U|--username)
4145 _pg_users
4146 return 0
4147 ;;
4148 -d|--dbname)
4149 _pg_databases
4150 return 0
4151 ;;
4152 -@(o|f)|--output|--file)
4153 _filedir
4154 return 0
4155 ;;
4156 esac
4157
4158 if [[ "$cur" == -* ]]; then
4159 # return list of available options
4160 COMPREPLY=( $( compgen -W '-a --echo-all -A --no-align \
4161 -c --command -d --dbname -e --echo-queries \
4162 -E --echo-hidden -f --file -F --filed-separator \
4163 -h --host -H --html -l --list -n -o --output \
4164 -p --port -P --pset -q -R --record-separator \
4165 -s --single-step -S --single-line -t --tuples-only \
4166 -T --table-attr -U --username -v --variable \
4167 -V --version -W --password -x --expanded -X --nopsqlrc \
4168 -? --help ' -- $cur ) )
4169 else
4170 # return list of available databases
4171 _pg_databases
4172 fi
4173 }
4174 complete -F _psql $default psql
4175 }
4176
4177 _longopt()
4178 {
4179 local cur opt
4180
4181 cur=`_get_cword`
4182
4183 if [[ "$cur" == --*=* ]]; then
4184 opt=${cur%%=*}
4185 # cut backslash that gets inserted before '=' sign
4186 opt=${opt%\\*}
4187 cur=${cur#*=}
4188 _filedir
4189 COMPREPLY=( $( compgen -P "$opt=" -W '${COMPREPLY[@]}' -- $cur))
4190 return 0
4191 fi
4192
4193 if [[ "$cur" == -* ]]; then
4194 COMPREPLY=( $( $1 --help 2>&1 | sed -e '/--/!d' \
4195 -e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
4196 command grep "^$cur" | sort -u ) )
4197 elif [[ "$1" == @(mk|rm)dir ]]; then
4198 _filedir -d
4199 else
4200 _filedir
4201 fi
4202 }
4203 # makeinfo and texi2dvi are defined elsewhere.
4204 for i in a2ps autoconf automake bc gprof ld nm objcopy objdump readelf strip \
4205 bison cpio diff patch enscript cp df dir du ln ls mkfifo mknod mv rm \
4206 touch vdir awk gperf grep grub indent less m4 sed shar date \
4207 tee who texindex cat csplit cut expand fmt fold head \
4208 md5sum nl od paste pr ptx sha1sum sort split tac tail tr unexpand \
4209 uniq wc ldd bash id irb mkdir rmdir; do
4210 have $i && complete -F _longopt $filenames $i
4211 done
4212
4213 # These commands use filenames, so '-o filenames' is not needed.
4214 for i in env netstat seq uname units wget; do
4215 have $i && complete -F _longopt $default $i
4216 done
4217 unset i
4218
4219 # gcc(1) completion
4220 #
4221 # The only unusual feature is that we don't parse "gcc --help -v" output
4222 # directly, because that would include the options of all the other backend
4223 # tools (linker, assembler, preprocessor, etc) without any indication that
4224 # you cannot feed such options to the gcc driver directly. (For example, the
4225 # linker takes a -z option, but you must type -Wl,-z for gcc.) Instead, we
4226 # ask the driver ("g++") for the name of the compiler ("cc1"), and parse the
4227 # --help output of the compiler.
4228 #
4229 have gcc &&
4230 _gcc()
4231 {
4232 local cur cc backend
4233
4234 COMPREPLY=()
4235 cur=`_get_cword`
4236
4237 _expand || return 0
4238
4239 case "$1" in
4240 gcj)
4241 backend=jc1
4242 ;;
4243 gpc)
4244 backend=gpc1
4245 ;;
4246 *77)
4247 backend=f771
4248 ;;
4249 *)
4250 backend=cc1 # (near-)universal backend
4251 ;;
4252 esac
4253
4254 if [[ "$cur" == -* ]]; then
4255 cc=$( $1 -print-prog-name=$backend )
4256 # sink stderr:
4257 # for C/C++/ObjectiveC it's useless
4258 # for FORTRAN/Java it's an error
4259 COMPREPLY=( $( $cc --help 2>/dev/null | tr '\t' ' ' | \
4260 sed -e '/^ *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | \
4261 command grep "^$cur" | sort -u ) )
4262 else
4263 _filedir
4264 fi
4265 } &&
4266 complete $filenames -F _gcc gcc g++ c++ g77 gcj gpc
4267 [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = Cygwin ] && \
4268 [ -n "${have:-}" ] && complete $filenames -F _gcc cc
4269
4270 # Linux cardctl(8) completion
4271 #
4272 have cardctl &&
4273 _cardctl()
4274 {
4275 local cur
4276
4277 COMPREPLY=()
4278 cur=`_get_cword`
4279
4280 if [ $COMP_CWORD -eq 1 ]; then
4281 COMPREPLY=( $( compgen -W 'status config ident suspend \
4282 resume reset eject insert scheme' \
4283 -- $cur ) )
4284 fi
4285 } &&
4286 complete -F _cardctl cardctl
4287
4288 # This function is required by _dpkg() and _dpkg-reconfigure()
4289 #
4290 have dpkg && {
4291 _comp_dpkg_installed_packages()
4292 {
4293 grep -A 1 "Package: $1" /var/lib/dpkg/status | \
4294 grep -B 1 -E "ok installed|half-installed|unpacked| \
4295 half-configured|config-files" | \
4296 grep "Package: $1" | cut -d\ -f2
4297 }
4298
4299 # Debian dpkg(8) completion
4300 #
4301 _dpkg()
4302 {
4303 local cur prev i
4304
4305 COMPREPLY=()
4306 cur=`_get_cword`
4307 prev=${COMP_WORDS[COMP_CWORD-1]}
4308 i=$COMP_CWORD
4309
4310 _expand || return 0
4311
4312 # find the last option flag
4313 if [[ $cur != -* ]]; then
4314 while [[ $prev != -* && $i != 1 ]]; do
4315 i=$((i-1))
4316 prev=${COMP_WORDS[i-1]}
4317 done
4318 fi
4319
4320 case "$prev" in
4321 -@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info|fsys-tarfile|field|control|extract)))
4322 _filedir '?(u)deb'
4323 return 0
4324 ;;
4325 -@(b|-build))
4326 _filedir -d
4327 return 0
4328 ;;
4329 -@(s|p|l|-@(status|print-avail|list)))
4330 COMPREPLY=( $( apt-cache pkgnames $cur 2>/dev/null ) )
4331 return 0
4332 ;;
4333 -@(S|-search))
4334 _filedir
4335 return 0
4336 ;;
4337 -@(r|L|P|-@(remove|purge|listfiles)))
4338 COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
4339 return 0
4340 ;;
4341 *)
4342
4343 COMPREPLY=( $( compgen -W '-i --install --unpack -A --record-avail \
4344 --configure -r --remove -P --purge --get-selections \
4345 --set-selections --update-avail --merge-avail \
4346 --clear-avail --command-fd --forget-old-unavail -s \
4347 --status -p --print-avail -L --listfiles -l --list \
4348 -S --search -C --audit --print-architecture \
4349 --print-gnu-build-architecture \
4350 --print-installation-architecture \
4351 --compare-versions --help --version --force-help \
4352 --force-all --force-auto-select --force-downgrade \
4353 --force-configure-any --force-hold --force-bad-path \
4354 --force-not-root --force-overwrite \
4355 --force-overwrite-diverted --force-bad-verify \
4356 --force-depends-version --force-depends \
4357 --force-confnew --force-confold --force-confdef \
4358 --force-confmiss --force-conflicts --force-architecture\
4359 --force-overwrite-dir --force-remove-reinstreq \
4360 --force-remove-essential -Dh \
4361 --debug=help --licence --admindir= --root= --instdir= \
4362 -O --selected-only -E --skip-same-version \
4363 -G --refuse-downgrade -B --auto-deconfigure \
4364 --no-debsig --no-act -D --debug= --status-fd \
4365 -b --build -I --info -f --field -c --contents \
4366 -x --extract -X --vextract --fsys-tarfile -e --control \
4367 --ignore-depends= --abort-after' -- $cur ) )
4368 ;;
4369 esac
4370
4371
4372 }
4373 complete -F _dpkg $filenames dpkg dpkg-deb
4374 }
4375
4376 # Debian GNU dpkg-reconfigure(8) completion
4377 #
4378 have dpkg-reconfigure &&
4379 _dpkg_reconfigure()
4380 {
4381 local cur prev opt
4382
4383 COMPREPLY=()
4384 cur=`_get_cword`
4385 prev=${COMP_WORDS[COMP_CWORD-1]}
4386
4387
4388 case "$prev" in
4389 -@(f|-frontend))
4390 opt=( $( echo /usr/share/perl5/Debconf/FrontEnd/* ) )
4391 opt=( ${opt[@]##*/} )
4392 opt=( ${opt[@]%.pm} )
4393 COMPREPLY=( $( compgen -W '${opt[@]}' -- $cur ) )
4394 return 0
4395 ;;
4396 -@(p|-priority))
4397 COMPREPLY=( $( compgen -W 'low medium high critical' -- $cur ) )
4398 return 0
4399 ;;
4400 esac
4401
4402 if [[ "$cur" == -* ]]; then
4403 COMPREPLY=( $( compgen -W '-f --frontend -p --priority -a --all \
4404 -u --unseen-only -h --help -s --showold \
4405 --force --terse' -- $cur ) )
4406 else
4407 COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
4408 fi
4409 } &&
4410 complete -F _dpkg_reconfigure $default dpkg-reconfigure
4411
4412 # Debian dpkg-source completion
4413 #
4414 have dpkg-source &&
4415 _dpkg_source()
4416 {
4417 local cur prev options work i action packopts unpackopts
4418
4419 packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sp -su -sr -ss -sn -sA -sK -sP -sU -sR"
4420 unpackopts="-sp -sn -su"
4421 options=`echo "-x -b $packopts $unpackopts" | xargs echo | sort -u | xargs echo`
4422
4423 COMPREPLY=()
4424 if [ "$1" != "dpkg-source" ]; then
4425 exit 1
4426 fi
4427 cur=`_get_cword`
4428 prev=${COMP_WORDS[COMP_CWORD-1]}
4429 action="options"
4430 for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
4431 if [[ ${COMP_WORDS[$i]} == "-x" ]]; then
4432 action=unpack
4433 elif [[ ${COMP_WORDS[$i]} == "-b" ]]; then
4434 action=pack
4435 elif [[ ${COMP_WORDS[$i]} == "-h" ]]; then
4436 action=help
4437 fi
4438 done
4439 # if currently seeing a complete option, return just itself.
4440 for i in $options; do
4441 if [ "$cur" = "$i" ]; then
4442 COMPREPLY=( "$cur" )
4443 return 0
4444 fi
4445 done
4446 case "$action" in
4447 "unpack")
4448 if [ "$cur" = "-" -o "$cur" = "-s" ]; then
4449 COMPREPLY=( $unpackots )
4450 return 0
4451 fi
4452 case "$prev" in
4453 "-x")
4454 COMPREPLY=( $( compgen -d -- "$cur" ) \
4455 $( compgen -f -X '!*.dsc' -- "$cur" ) )
4456 return 0
4457 ;;
4458 *)
4459 COMPREPLY=( $unpackopts $(compgen -d -f -- "$cur" ) )
4460 return 0
4461 ;;
4462 esac
4463 return 0
4464 ;;
4465 "pack")
4466 if [ "$cur" = "-" ]; then
4467 COMPREPLY=( $packopts )
4468 return 0
4469 fi
4470 if [ "$cur" = "-s" ]; then
4471 COMPREPLY=( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \
4472 "-sA" "-sK" "-sP" "-sU" "-sR" )
4473 return 0
4474 fi
4475 case "$prev" in
4476 "-b")
4477 COMPREPLY=( $( compgen -d -- "$cur" ) )
4478 return 0
4479 ;;
4480 "-c"|"-l"|"-T"|"-i"|"-I")
4481 # -c: get controlfile
4482 # -l: get per-version info from this file
4483 # -T: read variables here, not debian/substvars
4484 # -i: <regexp> filter out files to ignore diffs of.
4485 # -I: filter out files when building tarballs.
4486 # return directory names and file names
4487 COMPREPLY=( $( compgen -d -f ) )
4488 return 0
4489 ;;
4490 "-F")
4491 # -F: force change log format
4492 COMPREPLY=( $( ( cd /usr/lib/dpkg/parsechangelog; compgen -f "$cur" ) ) )
4493 return 0
4494 ;;
4495 "-V"|"-D")
4496 # -V: set a substitution variable
4497 # we don't know anything about possible variables or values
4498 # so we don't try to suggest any completion.
4499 COMPREPLY=()
4500 return 0
4501 ;;
4502 "-D")
4503 # -D: override or add a .dsc field and value
4504 # if $cur doesn't contain a = yet, suggest variable names
4505 if echo -- "$cur" | grep -q "="; then
4506 # $cur contains a "="
4507 COMPREPLY=()
4508 return 0
4509 else
4510 COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
4511 return 0
4512 fi
4513 ;;
4514 "-U")
4515 # -U: remove a field
4516 # Suggest possible fieldnames
4517 COMPREPLY=( Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files )
4518 return 0
4519 ;;
4520 *)
4521 COMPREPLY=( $packopts )
4522 return 0
4523 ;;
4524 esac
4525 return 0
4526 ;;
4527 *)
4528 # if seeing a partial option, return possible completions.
4529 if [ "$cur" = "-s" ]; then
4530 COMPREPLY=( "-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" \
4531 "-sA" "-sK" "-sP" "-sU" "-sR" )
4532 return 0
4533 fi
4534 # else return all possible options.
4535 COMPREPLY=( $options )
4536 return 0
4537 ;;
4538 esac
4539 } &&
4540 complete -F _dpkg_source dpkg-source
4541
4542 # Debian Linux dselect(8) completion.
4543 #
4544 have dselect &&
4545 _dselect()
4546 {
4547 local cur prev
4548
4549 COMPREPLY=()
4550 cur=`_get_cword`
4551 prev=${COMP_WORDS[COMP_CWORD-1]}
4552
4553 case "$prev" in
4554 --admindir)
4555 _filedir -d
4556 return 0
4557 ;;
4558
4559 -@(D|debug))
4560 _filedir
4561 return 0
4562 ;;
4563 esac
4564
4565 if [[ "$cur" == -* ]]; then
4566 COMPREPLY=( $( compgen -W '--admindir --help --version --licence \
4567 --license --expert --debug' -- $cur ) )
4568 else
4569 COMPREPLY=( $( compgen -W 'access update select install config \
4570 remove quit' -- $cur ) )
4571 fi
4572
4573
4574 return 0
4575 } &&
4576 complete -F _dselect $filenames dselect
4577
4578 # Java completion
4579 #
4580
4581 # available path elements completion
4582 have java && {
4583 _java_path()
4584 {
4585 cur=${cur##*:}
4586 _filedir '@(jar|zip)'
4587 }
4588
4589 # exact classpath determination
4590 _java_find_classpath()
4591 {
4592 local i
4593
4594 # search first in current options
4595 for (( i=1; i < COMP_CWORD; i++ )); do
4596 if [[ "${COMP_WORDS[i]}" == -@(cp|classpath) ]]; then
4597 classpath=${COMP_WORDS[i+1]}
4598 break
4599 fi
4600 done
4601
4602 # default to environment
4603 [ -z "$classpath" ] && classpath=$CLASSPATH
4604
4605 # default to current directory
4606 [ -z "$classpath" ] && classpath=.
4607 }
4608
4609 # exact sourcepath determination
4610 _java_find_sourcepath()
4611 {
4612 local i
4613
4614 # search first in current options
4615 for (( i=1; i < COMP_CWORD; i++ )); do
4616 if [[ "${COMP_WORDS[i]}" == -sourcepath ]]; then
4617 sourcepath=${COMP_WORDS[i+1]}
4618 break
4619 fi
4620 done
4621
4622 # default to classpath
4623 [ -z "$sourcepath" ] && _java_find_classpath
4624 sourcepath=$classpath
4625 }
4626
4627 # available classes completion
4628 _java_classes()
4629 {
4630 local classpath i
4631
4632 # find which classpath to use
4633 _java_find_classpath
4634
4635 # convert package syntax to path syntax
4636 cur=${cur//.//}
4637 # parse each classpath element for classes
4638 for i in ${classpath//:/ }; do
4639 if [ -r $i ] && [[ "$i" == *.@(jar|zip) ]]; then
4640 if type zipinfo &> /dev/null; then
4641 COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \
4642 "$i" | grep "^$cur" | grep '\.class$' | \
4643 grep -v "\\$" ) )
4644 else
4645 COMPREPLY=( "${COMPREPLY[@]}" $( jar tf "$i" \
4646 "$cur" | grep "\.class$" | grep -v "\\$" ) )
4647 fi
4648
4649 elif [ -d $i ]; then
4650 i=${i%/}
4651 COMPREPLY=( "${COMPREPLY[@]}" $( find "$i" -type f \
4652 -path "$i/$cur*.class" 2>/dev/null | \
4653 grep -v "\\$" | sed -e "s|^$i/||" ) )
4654 fi
4655 done
4656
4657 # remove class extension
4658 COMPREPLY=( ${COMPREPLY[@]%.class} )
4659 # convert path syntax to package syntax
4660 COMPREPLY=( ${COMPREPLY[@]//\//.} )
4661 }
4662
4663 # available packages completion
4664 _java_packages()
4665 {
4666 local sourcepath i
4667
4668 # find wich sourcepath to use
4669 _java_find_sourcepath
4670
4671 # convert package syntax to path syntax
4672 cur=${cur//.//}
4673 # parse each sourcepath element for packages
4674 for i in ${sourcepath//:/ }; do
4675 if [ -d $i ]; then
4676 COMPREPLY=( "${COMPREPLY[@]}" $( command ls -F -d \
4677 $i/$cur* 2>/dev/null | sed -e 's|^'$i'/||' ) )
4678 fi
4679 done
4680 # keep only packages
4681 COMPREPLY=( $( echo "${COMPREPLY[@]}" | tr " " "\n" | grep "/$" ) )
4682 # remove packages extension
4683 COMPREPLY=( ${COMPREPLY[@]%/} )
4684 # convert path syntax to package syntax
4685 cur=${COMPREPLY[@]//\//.}
4686 }
4687
4688 # java completion
4689 #
4690 _java()
4691 {
4692 local cur prev i
4693
4694 COMPREPLY=()
4695 cur=`_get_cword`
4696 prev=${COMP_WORDS[COMP_CWORD-1]}
4697
4698 for ((i=1; i < $COMP_CWORD; i++)); do
4699 case ${COMP_WORDS[$i]} in
4700 -cp|-classpath)
4701 ((i++)) # skip the classpath string.
4702 ;;
4703 -*)
4704 # this is an option, not a class/jarfile name.
4705 ;;
4706 *)
4707 # once we've seen a class, just do filename completion
4708 _filedir
4709 return 0
4710 ;;
4711 esac
4712 done
4713
4714 case $prev in
4715 -@(cp|classpath))
4716 _java_path
4717 return 0
4718 ;;
4719 esac
4720
4721 if [[ "$cur" == -* ]]; then
4722 # relevant options completion
4723 COMPREPLY=( $( compgen -W '-client -hotspot -server -classic \
4724 -cp -classpath -D -verbose -verbose:class \
4725 -verbose:gc -version:jni -version \
4726 -showversion -? -help -X -jar \
4727 -ea -enableassertions -da -disableassertions \
4728 -esa -enablesystemassertions \
4729 -dsa -disablesystemassertions ' -- $cur ) )
4730 else
4731 if [[ "$prev" == -jar ]]; then
4732 # jar file completion
4733 _filedir jar
4734 else
4735 # classes completion
4736 _java_classes
4737 fi
4738 fi
4739 }
4740 complete -F _java $filenames java
4741 }
4742
4743 # javadoc completion
4744 #
4745 have javadoc &&
4746 _javadoc()
4747 {
4748 COMPREPLY=()
4749 local cur prev
4750
4751 cur=`_get_cword`
4752 prev=${COMP_WORDS[COMP_CWORD-1]}
4753
4754 case $prev in
4755 -@(overview|helpfile|stylesheetfile))
4756 _filedir
4757 return 0
4758 ;;
4759 -d)
4760 _filedir -d
4761 return 0
4762 ;;
4763 -@(classpath|bootclasspath|docletpath|sourcepath|extdirs))
4764 _java_path
4765 return 0
4766 ;;
4767 esac
4768
4769 if [[ "$cur" == -* ]]; then
4770 # relevant options completion
4771 COMPREPLY=( $( compgen -W '-overview -public -protected \
4772 -package -private -help -doclet -docletpath \
4773 -sourcepath -classpath -exclude -subpackages \
4774 -breakiterator -bootclasspath -source -extdirs \
4775 -verbose -locale -encoding -J -d -use -version \
4776 -author -docfilessubdirs -splitindex \
4777 -windowtitle -doctitle -header -footer -bottom \
4778 -link -linkoffline -excludedocfilessubdir \
4779 -group -nocomment -nodeprecated -noqualifier \
4780 -nosince -nodeprecatedlist -notree -noindex \
4781 -nohelp -nonavbar -quiet -serialwarn -tag \
4782 -taglet -tagletpath -charset -helpfile \
4783 -linksource -stylesheetfile -docencoding' -- \
4784 $cur ) )
4785 else
4786 # source files completion
4787 _filedir java
4788 # packages completion
4789 _java_packages
4790 fi
4791 } &&
4792 complete -F _javadoc $filenames javadoc
4793
4794 # javac completion
4795 #
4796 have javac &&
4797 _javac()
4798 {
4799 COMPREPLY=()
4800 local cur prev
4801
4802 cur=`_get_cword`
4803 prev=${COMP_WORDS[COMP_CWORD-1]}
4804
4805 case $prev in
4806 -d)
4807 _filedir -d
4808 return 0
4809 ;;
4810 -@(classpath|bootclasspath|sourcepath|extdirs))
4811 _java_path
4812 return 0
4813 ;;
4814 esac
4815
4816 if [[ "$cur" == -* ]]; then
4817 # relevant options completion
4818 COMPREPLY=( $( compgen -W '-g -g:none -g:lines -g:vars\
4819 -g:source -O -nowarn -verbose -deprecation -classpath\
4820 -sourcepath -bootclasspath -extdirs -d -encoding -source\
4821 -target -help' -- $cur ) )
4822 else
4823 # source files completion
4824 _filedir java
4825 fi
4826 } &&
4827 complete -F _javac $filenames javac
4828
4829 # PINE address-book completion
4830 #
4831 have pine &&
4832 _pineaddr()
4833 {
4834 local cur
4835
4836 COMPREPLY=()
4837 cur=`_get_cword`
4838
4839 COMPREPLY=( $( compgen -W '$( awk "{print \$1}" ~/.addressbook 2>/dev/null)' \
4840 -- $cur ) )
4841 } &&
4842 complete -F _pineaddr $default pine
4843
4844 # mutt completion
4845 #
4846 # Mutt doesn't have an "addressbook" like Pine, but it has aliases and
4847 # a "query" function to retrieve addresses, so that's what we use here.
4848 have mutt || have muttng && {
4849 _muttaddr()
4850 {
4851 _muttaliases
4852 _muttquery
4853 return 0
4854 }
4855
4856 _muttconffiles()
4857 {
4858 local file sofar
4859 local -a newconffiles
4860
4861 sofar=" $1 "
4862 shift
4863 while [[ "$1" ]]; do
4864 newconffiles=( $(sed -rn 's|^source[[:space:]]+([^[:space:]]+).*$|\1|p' $(eval echo $1) ) )
4865 for file in "${newconffiles[@]}"; do
4866 [[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] &&
4867 continue
4868 sofar="$sofar $file"
4869 sofar=" $(eval _muttconffiles \"$sofar\" $file) "
4870 done
4871 shift
4872 done
4873 echo $sofar
4874 }
4875
4876 _muttaliases()
4877 {
4878 local cur muttrc
4879 local -a conffiles aliases
4880 cur=`_get_cword`
4881
4882 [ -f ~/.${muttcmd}/${muttcmd}rc ] && muttrc="~/.${muttcmd}/${muttcmd}rc"
4883 [ -f ~/.${muttcmd}rc ] && muttrc="~/.${muttcmd}rc"
4884 [ -z "$muttrc" ] && return 0
4885
4886 conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
4887 aliases=( $( sed -rn 's|^alias[[:space:]]+([^[:space:]]+).*$|\1|p' \
4888 $(eval echo "${conffiles[@]}") ) )
4889 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- $cur ) )
4890
4891 return 0
4892 }
4893
4894 _muttquery()
4895 {
4896 local cur querycmd
4897 local -a queryresults
4898 cur=`_get_cword`
4899
4900 querycmd="$( $muttcmd -Q query_command | sed -r 's|^query_command=\"(.*)\"$|\1|; s|%s|'$cur'|' )"
4901 if [ -z "$cur" -o -z "$querycmd" ]; then
4902 queryresults=()
4903 else
4904 queryresults=( $( $querycmd | \
4905 sed -nr '2,$s|^([^[:space:]]+).*|\1|p' ) )
4906 fi
4907
4908 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}" \
4909 -- $cur ) )
4910
4911 return 0
4912 }
4913
4914 _muttfiledir()
4915 {
4916 local cur folder spoolfile
4917 cur=`_get_cword`
4918
4919 # This is currently not working so well. Perhaps this function should
4920 # just call _filedir() for the moment.
4921 if [[ $cur == [=+]* ]]; then
4922 folder="$( $muttcmd -Q folder | sed -r 's|^folder=\"(.*)\"$|\1|' )"
4923 : folder:=~/Mail
4924
4925 # Match any file in $folder beginning with $cur
4926 # (minus the leading '=' sign).
4927 COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) )
4928 COMPREPLY=( ${COMPREPLY[@]#$folder/} )
4929 return 0
4930 elif [ "$cur" == !* ]; then
4931 spoolfile="$( $muttcmd -Q spoolfile | sed -r 's|^spoolfile=\"(.*)\"$|\1|' )"
4932 [ ! -z "$spoolfile" ] && eval cur="${cur/^!/$spoolfile}";
4933 fi
4934 _filedir
4935
4936 return 0
4937 }
4938
4939 _mutt()
4940 {
4941 local cur prev
4942 cur=`_get_cword`
4943 prev=${COMP_WORDS[COMP_CWORD-1]}
4944
4945 COMPREPLY=()
4946
4947 [ ${COMP_WORDS[0]} == muttng ] && muttcmd="muttng" || muttcmd="mutt"
4948
4949 case "$cur" in
4950 -*)
4951 COMPREPLY=( $( compgen -W '-A -a -b -c -e -f -F -H -i -m -n \
4952 -p -Q -R -s -v -x -y -z -Z -h' \
4953 -- $cur ) )
4954 return 0
4955 ;;
4956 *)
4957 case "$prev" in
4958 -@(a|f|F|H|i))
4959 _muttfiledir
4960 return 0
4961 ;;
4962 -A)
4963 _muttaliases
4964 return 0
4965 ;;
4966 -@(e|m|Q|s|h|p|R|v|y|z|Z))
4967 return 0
4968 ;;
4969 *)
4970 _muttaddr
4971 return 0
4972 ;;
4973 esac
4974 ;;
4975 esac
4976
4977 }
4978 complete -F _mutt $default $filenames mutt muttng
4979 }
4980
4981 _configure_func()
4982 {
4983 local cur
4984
4985 COMPREPLY=()
4986 cur=`_get_cword`
4987
4988 # if $COMP_CONFIGURE_HINTS is not null, then completions of the form
4989 # --option=SETTING will include 'SETTING' as a contextual hint
4990 [[ "$cur" != -* ]] && return 0
4991
4992 if [ -n "$COMP_CONFIGURE_HINTS" ]; then
4993 COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' | grep ^$cur ) )
4994
4995 else
4996 COMPREPLY=( $( $1 --help | awk '/^ --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' | grep ^$cur ) )
4997 fi
4998 }
4999 complete -F _configure_func $default configure
5000
5001 # Debian reportbug(1) completion
5002 #
5003 have reportbug &&
5004 _reportbug()
5005 {
5006 local cur prev
5007
5008 COMPREPLY=()
5009 cur=`_get_cword`
5010 prev=${COMP_WORDS[COMP_CWORD-1]}
5011
5012 case "$prev" in
5013 -f|--filename|-i|--include|--mta|-o|--output)
5014 _filedir
5015 return 0
5016 ;;
5017 -B|--bts)
5018 COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \
5019 $cur ))
5020 return 0
5021 ;;
5022 -e|--editor|--mua)
5023 COMP_WORDS=(COMP_WORDS[0] $cur)
5024 COMP_CWORD=1
5025 _command
5026 return 0
5027 ;;
5028 --mode)
5029 COMPREPLY=( $( compgen -W "novice standard expert" -- $cur ) )
5030 return 0
5031 ;;
5032 -S|--severity)
5033 COMPREPLY=( $( compgen -W "grave serious important normal \
5034 minor wishlist" -- $cur ) )
5035 return 0
5036 ;;
5037 -u|--ui|--interface)
5038 COMPREPLY=( $( compgen -W "newt text gnome" -- $cur ) )
5039 return 0
5040 ;;
5041 -t|--type)
5042 COMPREPLY=( $( compgen -W "gnats debbugs" -- $cur ) )
5043 return 0
5044 ;;
5045 -T|--tags)
5046 COMPREPLY=( $( compgen -W "none patch security upstream sid \
5047 woody potato sarge fixed" -- $cur ))
5048 return 0
5049 ;;
5050 *)
5051 ;;
5052 esac
5053
5054 COMPREPLY=($( compgen -W '-h --help -v --version -a --af -b \
5055 --no-query-bts --query-bts -B --bts -c --configure \
5056 --no-config-files --check-available -d --debug \
5057 --no-check-available -e --editor --email -f \
5058 --filename -g --gnupg -H --header -i --include -j \
5059 --justification -l --ldap --no-ldap -L --list-cc -m \
5060 --maintonly --mode --mua --mta --mutt -n --mh --nmh \
5061 -o --output -p --print -P --pgp --proxy --http_proxy\
5062 -q --quiet -Q --query-only --realname --report-quiet \
5063 --reply-to --replyto -s --subject -S --severity \
5064 --smtphost -t --type -T --tags --template -V -x \
5065 --no-cc --package-version -z --no-compress \
5066 --ui --interface -u \
5067 wnpp boot-floppies kernel-image' -- $cur ) \
5068 $( apt-cache pkgnames -- $cur 2> /dev/null ) )
5069 _filedir
5070 return 0
5071 } &&
5072 complete -F _reportbug $filenames reportbug
5073
5074 # Debian querybts(1) completion
5075 #
5076 have querybts &&
5077 _querybts()
5078 {
5079 local cur prev
5080
5081 COMPREPLY=()
5082 cur=`_get_cword`
5083 prev=${COMP_WORDS[COMP_CWORD-1]}
5084
5085 case "$prev" in
5086 -B|--bts)
5087 COMPREPLY=( $( compgen -W "debian guug kde mandrake help" -- \
5088 $cur ))
5089 return 0
5090 ;;
5091 -u|--ui|--interface)
5092 COMPREPLY=($( compgen -W "newt text gnome" -- $cur ))
5093 return 0
5094 ;;
5095 *)
5096 ;;
5097 esac
5098
5099 COMPREPLY=($( compgen -W '-h --help -v --version -A --archive \
5100 -B --bts -l --ldap --no-ldap --proxy= --http_proxy= \
5101 -s --source -w --web -u --ui --interface \
5102 wnpp boot-floppies' -- $cur ) \
5103 $( apt-cache pkgnames -- $cur 2> /dev/null ) )
5104 } &&
5105 complete -F _querybts $filenames querybts
5106
5107 # update-alternatives completion
5108 #
5109 have update-alternatives && {
5110 installed_alternatives()
5111 {
5112 local admindir
5113 # find the admin dir
5114 for i in alternatives dpkg/alternatives rpm/alternatives; do
5115 [ -d /var/lib/$i ] && admindir=/var/lib/$i && break
5116 done
5117 for (( i=1; i < COMP_CWORD; i++ )); do
5118 if [[ "${COMP_WORDS[i]}" == --admindir ]]; then
5119 admindir=${COMP_WORDS[i+1]}
5120 break
5121 fi
5122 done
5123 COMPREPLY=( $( command ls $admindir | grep "^$cur" ) )
5124 }
5125
5126 _update_alternatives()
5127 {
5128 local cur prev mode args i
5129
5130 COMPREPLY=()
5131 cur=`_get_cword`
5132 prev=${COMP_WORDS[COMP_CWORD-1]}
5133
5134 case "$prev" in
5135 --@(altdir|admindir))
5136 _filedir -d
5137 return 0
5138 ;;
5139 --@(help|version))
5140 return 0
5141 ;;
5142 esac
5143
5144 # find wich mode to use and how many real args used so far
5145 for (( i=1; i < COMP_CWORD; i++ )); do
5146 if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all) ]]; then
5147 mode=${COMP_WORDS[i]}
5148 args=$(($COMP_CWORD - i))
5149 break
5150 fi
5151 done
5152
5153 case $mode in
5154 --install)
5155 case $args in
5156 1)
5157 _filedir
5158 ;;
5159 2)
5160 installed_alternatives
5161 ;;
5162 3)
5163 _filedir
5164 ;;
5165 esac
5166 ;;
5167 --remove)
5168 case $args in
5169 1)
5170 installed_alternatives
5171 ;;
5172 2)
5173 _filedir
5174 ;;
5175 esac
5176 ;;
5177 --auto)
5178 installed_alternatives
5179 ;;
5180 --remove-all)
5181 installed_alternatives
5182 ;;
5183 --display)
5184 installed_alternatives
5185 ;;
5186 --config)
5187 installed_alternatives
5188 ;;
5189 *)
5190 COMPREPLY=( $( compgen -W '--verbose --quiet --help --version \
5191 --altdir --admindir' -- $cur ) \
5192 $( compgen -W '--install --remove --auto --display \
5193 --config' -- $cur ) )
5194 esac
5195 }
5196 complete -F _update_alternatives update-alternatives
5197 }
5198
5199 # Python completion
5200 #
5201 have python &&
5202 _python()
5203 {
5204 local prev cur
5205
5206 COMPREPLY=()
5207 cur=`_get_cword`
5208 prev=${COMP_WORDS[COMP_CWORD-1]##*/}
5209
5210 case "$prev" in
5211 -Q)
5212 COMPREPLY=( $( compgen -W "old new warn warnall" -- $cur ) )
5213 return 0
5214 ;;
5215 -W)
5216 COMPREPLY=( $( compgen -W "ignore default all module once error" -- $cur ) )
5217 return 0
5218 ;;
5219 -c)
5220 _filedir '@(py|pyc|pyo)'
5221 return 0
5222 ;;
5223 !(python|-?))
5224 [[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] && _filedir
5225 ;;
5226 esac
5227
5228
5229 # if '-c' is already given, complete all kind of files.
5230 for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
5231 if [[ ${COMP_WORDS[i]} == -c ]]; then
5232 _filedir
5233 fi
5234 done
5235
5236
5237 if [[ "$cur" != -* ]]; then
5238 _filedir '@(py|pyc|pyo)'
5239 else
5240 COMPREPLY=( $( compgen -W "- -d -E -h -i -O -Q -S -t -u \
5241 -U -v -V -W -x -c" -- $cur ) )
5242 fi
5243
5244
5245
5246 return 0
5247 } &&
5248 complete -F _python $filenames python
5249
5250 # Perl completion
5251 #
5252 have perl &&
5253 {
5254 _perlmodules()
5255 {
5256 COMPREPLY=( $( compgen -P "$prefix" -W "$( perl -e 'sub mods { my ($base,$dir)=@_; return if $base !~ /^\Q$ENV{cur}/; chdir($dir) or return; for (glob(q[*.pm])) {s/\.pm$//; print qq[$base$_\n]}; mods(/^(?:[.\d]+|$Config{archname}-$Config{osname}|auto)$/ ? undef : qq[${base}${_}\\\\:\\\\:],qq[$dir/$_]) for grep {-d} glob(q[*]); } mods(undef,$_) for @INC;' )" -- $cur ) )
5257 }
5258
5259 _perl()
5260 {
5261 local cur prev prefix temp
5262
5263 COMPREPLY=()
5264 cur=`_get_cword`
5265 prev=${COMP_WORDS[COMP_CWORD-1]}
5266 prefix=""
5267
5268 # completing an option (may or may not be separated by a space)
5269 if [[ "$cur" == -?* ]]; then
5270 temp=$cur
5271 prev=${temp:0:2}
5272 cur=${temp:2}
5273 prefix=$prev
5274 fi
5275
5276 # only handle module completion for now
5277 case "$prev" in
5278 -I|-x)
5279 COMPREPLY=( $( compgen -d -P "$prev" -- "$cur" ) )
5280 return 0
5281 ;;
5282 -m|-M)
5283 _perlmodules
5284 return 0
5285 ;;
5286 esac
5287
5288 # handle case where first parameter is not a dash option
5289 if [[ "${COMP_WORDS[COMP_CWORD]}" != -* ]]; then
5290 _filedir
5291 return 0
5292 fi
5293
5294 # complete using basic options
5295 COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \
5296 -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
5297 return 0
5298 }
5299 complete -F _perl $filenames perl
5300
5301 _perldoc()
5302 {
5303 local cur prev prefix temp
5304
5305 COMPREPLY=()
5306 cur=`_get_cword`
5307 prev=${COMP_WORDS[COMP_CWORD-1]}
5308 prefix=""
5309
5310 # completing an option (may or may not be separated by a space)
5311 if [[ "$cur" == -?* ]]; then
5312 temp=$cur
5313 prev=${temp:0:2}
5314 cur=${temp:2}
5315 prefix=$prev
5316 fi
5317
5318 # complete builtin perl functions
5319 case $prev in
5320 -f)
5321 COMPREPLY=( $( compgen -W 'chomp chop chr crypt hex index lc \
5322 lcfirst length oct ord pack q qq reverse rindex sprintf \
5323 substr tr uc ucfirst y m pos quotemeta s split study qr abs \
5324 atan2 cos exp hex int log oct rand sin sqrt srand pop push \
5325 shift splice unshift grep join map qw reverse sort unpack \
5326 delete each exists keys values binmode close closedir \
5327 dbmclose dbmopen die eof fileno flock format getc print \
5328 printf read readdir rewinddir seek seekdir select syscall \
5329 sysread sysseek syswrite tell telldir truncate warn write \
5330 pack read syscall sysread syswrite unpack vec -X chdir chmod \
5331 chown chroot fcntl glob ioctl link lstat mkdir open opendir \
5332 readlink rename rmdir stat symlink umask unlink utime caller \
5333 continue do dump eval exit goto last next redo return \
5334 sub wantarray caller import local my our package use defined \
5335 formline reset scalar undef \
5336 alarm exec fork getpgrp getppid getpriority kill pipe qx \
5337 setpgrp setpriority sleep system times wait waitpid \
5338 import no package require use bless dbmclose dbmopen package \
5339 ref tie tied untie use accept bind connect getpeername \
5340 getsockname getsockopt listen recv send setsockopt shutdown \
5341 socket socketpair msgctl msgget msgrcv msgsnd semctl semget \
5342 semop shmctl shmget shmread shmwrite endgrent endhostent \
5343 endnetent endpwent getgrent getgrgid getgrnam getlogin \
5344 getpwent getpwnam getpwuid setgrent setpwent endprotoent \
5345 endservent gethostbyaddr gethostbyname gethostent \
5346 getnetbyaddr getnetbyname getnetent getprotobyname \
5347 getprotobynumber getprotoent getservbyname getservbyport \
5348 getservent sethostent setnetent setprotoent setservent \
5349 gmtime localtime time times' -- $cur ) )
5350 return 0
5351 ;;
5352 esac
5353
5354 case $cur in
5355 -*)
5356 COMPREPLY=( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur ))
5357 return 0
5358 ;;
5359 */*)
5360 return 0
5361 ;;
5362 *)
5363 _perlmodules
5364 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=cat man perl 2>/dev/null | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ) )
5365
5366 return 0
5367 ;;
5368 esac
5369 }
5370 complete -F _perldoc $default perldoc
5371 }
5372
5373 # rcs(1) completion
5374 #
5375 have rcs &&
5376 _rcs()
5377 {
5378 local cur prev file dir i
5379
5380 COMPREPLY=()
5381 cur=`_get_cword`
5382 prev=${COMP_WORDS[COMP_CWORD-1]}
5383
5384 file=${cur##*/}
5385 dir=${cur%/*}
5386
5387 # deal with relative directory
5388 [ "$file" = "$dir" ] && dir=.
5389
5390 COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) )
5391
5392 for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
5393 file=${COMPREPLY[$i]##*/}
5394 dir=${COMPREPLY[$i]%RCS/*}
5395 COMPREPLY[$i]=$dir$file
5396 done
5397
5398 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -G "$dir/$file*,v" ) )
5399
5400 for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
5401 COMPREPLY[$i]=${COMPREPLY[$i]%,v}
5402 done
5403
5404 # default to files if nothing returned and we're checking in.
5405 # otherwise, default to directories
5406 [ ${#COMPREPLY[@]} -eq 0 -a $1 = ci ] && _filedir || _filedir -d
5407 } &&
5408 complete -F _rcs $filenames ci co rlog rcs rcsdiff
5409
5410 # lilo(8) completion
5411 #
5412 have lilo && {
5413 _lilo_labels()
5414 {
5415 COMPREPLY=( $( awk -F'=' '/label/ {print $2}' \
5416 /etc/lilo.conf | sed -e 's/"//g' | grep "^$cur" ) )
5417 }
5418
5419 _lilo()
5420 {
5421 local cur prev
5422
5423 COMPREPLY=()
5424 cur=`_get_cword`
5425 prev=${COMP_WORDS[COMP_CWORD-1]}
5426
5427 case $prev in
5428 -@(C|i|m|s|S))
5429 _filedir
5430 return 0
5431 ;;
5432 -r)
5433 _filedir -d
5434 return 0
5435 ;;
5436 -@(I|D|R))
5437 # label completion
5438 _lilo_labels
5439 return 0
5440 ;;
5441 -@(A|b|M|u|U))
5442 # device completion
5443 cur=${cur:=/dev/}
5444 _filedir
5445 return 0
5446 ;;
5447 -T)
5448 # topic completion
5449 COMPREPLY=( $( compgen -W 'help ChRul EBDA geom geom= \
5450 table= video' -- $cur ) )
5451 return 0
5452 ;;
5453 esac
5454
5455 if [[ "$cur" == -* ]]; then
5456 # relevant options completion
5457 COMPREPLY=( $( compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m \
5458 -M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- \
5459 $cur ) )
5460 fi
5461 }
5462 complete -F _lilo lilo
5463 }
5464
5465 # links completion
5466 #
5467 have links &&
5468 _links()
5469 {
5470 local cur
5471
5472 COMPREPLY=()
5473 cur=`_get_cword`
5474
5475 case "$cur" in
5476 --*)
5477 COMPREPLY=( $( compgen -W '--help' -- $cur ) )
5478 ;;
5479 -*)
5480 COMPREPLY=( $( compgen -W '-async-dns -max-connections \
5481 -max-connections-to-host -retries \
5482 -receive-timeout -unrestartable-receive-timeout\
5483 -format-cache-size -memory-cache-size \
5484 -http-proxy -ftp-proxy -download-dir \
5485 -assume-codepage -anonymous -dump -no-connect \
5486 -source -version -help' -- $cur ) )
5487 ;;
5488 *)
5489 if [ -r ~/.links/links.his ]; then
5490 COMPREPLY=( $( compgen -W '$( < ~/.links/links.his )' \
5491 -- $cur ) )
5492 fi
5493 _filedir '@(htm|html)'
5494 return 0
5495 ;;
5496 esac
5497
5498 return 0
5499 } &&
5500 complete -F _links $filenames links
5501
5502 [ $UNAME = FreeBSD ] && {
5503 # FreeBSD package management tool completion
5504 #
5505 _pkg_delete()
5506 {
5507 local cur pkgdir prev
5508
5509 pkgdir=${PKG_DBDIR:-/var/db/pkg}/
5510 cur=`_get_cword`
5511 prev=${COMP_WORDS[COMP_CWORD-1]}
5512
5513 [ "$prev" = "-o" -o "$prev" = "-p" -o "$prev" = "-W" ] && return 0
5514
5515 COMPREPLY=( $( compgen -d $pkgdir$cur ) )
5516 COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
5517
5518 return 0
5519 }
5520 complete -F _pkg_delete $dirnames pkg_delete pkg_info
5521 have pkg_deinstall && complete -F _pkg_delete $dirnames pkg_deinstall
5522
5523 # FreeBSD kernel module commands
5524 #
5525 _kldload()
5526 {
5527 local cur moddir
5528
5529 moddir=/modules/
5530 [ -d $moddir ] || moddir=/boot/kernel/
5531 cur=`_get_cword`
5532
5533 COMPREPLY=( $( compgen -f $moddir$cur ) )
5534 COMPREPLY=( ${COMPREPLY[@]#$moddir} )
5535 COMPREPLY=( ${COMPREPLY[@]%.ko} )
5536
5537 return 0
5538 }
5539 complete -F _kldload $filenames kldload
5540
5541 _kldunload()
5542 {
5543 local cur
5544 cur=`_get_cword`
5545 COMPREPLY=( $(kldstat | sed -ne "s/^.*[ \t]\+\($cur[a-z_]\+\).ko$/\1/p") )
5546 }
5547 complete -F _kldunload $filenames kldunload
5548 }
5549
5550 # FreeBSD portupgrade completion
5551 #
5552 have portupgrade &&
5553 _portupgrade()
5554 {
5555 local cur pkgdir prev
5556
5557 pkgdir=${PKG_DBDIR:-/var/db/pkg}/
5558 cur=`_get_cword`
5559 prev=${COMP_WORDS[COMP_CWORD-1]}
5560
5561 [ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
5562
5563 COMPREPLY=( $( compgen -d $pkgdir$cur ) )
5564 COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
5565 COMPREPLY=( ${COMPREPLY[@]%-*} )
5566
5567 return 0
5568 } &&
5569 complete -F _portupgrade $dirnames portupgrade
5570
5571 # FreeBSD portinstall completion
5572 #
5573 have portinstall &&
5574 _portinstall()
5575 {
5576 local cur portsdir prev indexfile
5577 local -a COMPREPLY2
5578
5579 portsdir=${PORTSDIR:-/usr/ports}/
5580 cur=`_get_cword`
5581 prev=${COMP_WORDS[COMP_CWORD-1]}
5582 # First try INDEX-5
5583 indexfile=$portsdir/INDEX-5
5584 # Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
5585 [ "${OSTYPE%.*}" = "freebsd5" -a -f $indexfile ] ||
5586 indexfile=$portsdir/INDEX
5587
5588 [ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
5589
5590 COMPREPLY=( $( egrep "^$cur" < $indexfile | cut -d'|' -f1 ) )
5591 COMPREPLY2=( $( egrep "^[^\|]+\|$portsdir$cur" < $indexfile | \
5592 cut -d'|' -f2 ) )
5593 COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
5594 COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" )
5595
5596 return 0
5597 } &&
5598 complete -F _portinstall $dirnames portinstall
5599
5600 # Slackware Linux removepkg completion
5601 #
5602 have removepkg && [ -f /etc/slackware-version ] &&
5603 _removepkg()
5604 {
5605 local packages cur
5606
5607 COMPREPLY=()
5608 cur=`_get_cword`
5609
5610 COMPREPLY=( $( (cd /var/log/packages; compgen -f -- "$cur") ) )
5611 } &&
5612 complete -F _removepkg $filenames removepkg &&
5613 complete $dirnames -f -X '!*.tgz' installpkg upgradepkg explodepkg
5614
5615 # look(1) completion
5616 #
5617 have look &&
5618 _look()
5619 {
5620 local cur
5621
5622 COMPREPLY=()
5623 cur=`_get_cword`
5624
5625 if [ $COMP_CWORD = 1 ]; then
5626 COMPREPLY=( $( compgen -W '$(look $cur)' ) )
5627 fi
5628 } &&
5629 complete -F _look $default look
5630
5631 # ypcat(1) and ypmatch(1) completion
5632 #
5633 have ypmatch &&
5634 _ypmatch()
5635 {
5636 local cur map
5637
5638 COMPREPLY=()
5639 cur=`_get_cword`
5640
5641 [ $1 = ypcat ] && [ $COMP_CWORD -gt 1 ] && return 0
5642 [ $1 = ypmatch ] && [ $COMP_CWORD -gt 2 ] && return 0
5643
5644 if [ $1 = ypmatch ] && [ $COMP_CWORD -eq 1 ] && \
5645 [ ${#COMP_WORDS[@]} -eq 3 ]; then
5646 map=${COMP_WORDS[2]}
5647 COMPREPLY=( $( compgen -W '$( ypcat $map | \
5648 cut -d':' -f 1 )' -- $cur) )
5649 else
5650 [ $1 = ypmatch ] && [ $COMP_CWORD -ne 2 ] && return 0
5651 COMPREPLY=( $( compgen -W \
5652 '$( echo $(ypcat -x | cut -d"\"" -f 2))' -- $cur))
5653 fi
5654
5655 return 0
5656 } &&
5657 complete -F _ypmatch ypmatch ypcat
5658
5659 # mplayer(1) completion
5660 #
5661 have mplayer && {
5662 _mplayer_options_list()
5663 {
5664 cur=${cur%\\}
5665 COMPREPLY=( $( $1 $2 help 2> /dev/null | \
5666 sed -e '1,/^Available/d' | awk '{print $1}' | \
5667 sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' | \
5668 grep "^$cur" ) )
5669 }
5670
5671 _mplayer()
5672 {
5673 local cmd cur prev skinsdir IFS=$' \t\n' i j k=0
5674
5675 COMPREPLY=()
5676 cmd=${COMP_WORDS[0]}
5677 cur=`_get_cword`
5678 prev=${COMP_WORDS[COMP_CWORD-1]}
5679
5680 case "$prev" in
5681 -@(ac|afm|vc|vfm|ao|vo|vop|fstype))
5682 _mplayer_options_list mplayer $prev
5683 return 0
5684 ;;
5685 -@(oac|ovc|of))
5686 _mplayer_options_list mencoder $prev
5687 return 0
5688 ;;
5689 -audiofile)
5690 _filedir '@(mp3|MP3|mpg|MPG|ogg|OGG|wav|WAV|mid|MID|flac|FLAC|mka|MKA)'
5691 return 0
5692 ;;
5693 -font)
5694 _filedir '@(desc|ttf)'
5695 return 0
5696 ;;
5697 -sub)
5698 _filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js|ssa|SSA|aas|AAS)'
5699 return 0
5700 ;;
5701 -vobsub)
5702 _filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
5703 IFS=$'\t\n'
5704 COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do
5705 if [ -f $i -a -r $i ]; then
5706 echo ${i%.*}
5707 else
5708 echo $i
5709 fi
5710 done ) )
5711 IFS=$' \t\n'
5712 return 0
5713 ;;
5714 -ifo)
5715 _filedir '@(ifo|IFO)'
5716 return 0
5717 ;;
5718 -cuefile)
5719 _filedir '@(bin|BIN|cue|CUE)'
5720 return 0
5721 ;;
5722 -skin)
5723 # if you don't have installed mplayer in /usr/local you
5724 # may want to set the MPLAYER_SKINS_DIR global variable
5725 if [ -n "$MPLAYER_SKINS_DIR" ]; then
5726 skinsdir=$MPLAYER_SKINS_DIR
5727 else
5728 skinsdir=/usr/local/share/mplayer/Skin
5729 fi
5730
5731 IFS=$'\t\n'
5732 for i in ~/.mplayer/Skin $skinsdir; do
5733 if [ -d $i -a -r $i ]; then
5734 for j in $( compgen -d $i/$cur ); do
5735 COMPREPLY[$k]=${j#$i/}
5736 k=$((++k))
5737 done
5738 fi
5739 done
5740 IFS=$' \t\n'
5741 return 0
5742 ;;
5743 -@(mixer|@(cdrom|dvd)-device|dvdauth|fb|zrdev))
5744 cur=${cur:=/dev/}
5745 _filedir
5746 return 0
5747 ;;
5748 -@(edl?(out)|lircconf|menu-cfg|playlist|csslib|dumpfile)| \
5749 -@(subfile|vobsub|aofile|fbmodeconfig|include|o|dvdkey)| \
5750 -passlogfile)
5751 _filedir
5752 return 0
5753 ;;
5754 -@(auto@(q|sync)|loop|menu-root|speed|sstep|aid|alang)| \
5755 -@(?(@(audio|sub)-)demuxer|bandwidth|cache|chapter)| \
5756 -@(dvd?(angle)|fps|frames|mc|passwd|user|sb|srate|ss|vcd)| \
5757 -@(vi?(d|vo)|ffactor|sid|slang|spu@(align|aa|gauss))| \
5758 -@(vobsubid|delay|bpp|brightness|contrast|dfbopts|display)| \
5759 -@(fbmode|geometry|guiwid|hue|icelayer|screen[wh]|wid)| \
5760 -@(monitor@(aspect|-@(dotclock|[hv]freq))|panscan|saturation)| \
5761 -@(xineramascreen|zr@(crop|norm|quality|[xy]doff|[vh]dec))| \
5762 -@(aspect|pp|x|y|xy|z|stereo|audio-@(density|delay|preload))| \
5763 -@(endpos|osdlevel|ffourcc|sws|channels|skiplimit|format)| \
5764 -@(ofps|aa@(driver|@(osd|sub)color)|vobsubout?(i@(ndex|d)))| \
5765 -sub@(-bg-@(alpha|color)|cp|delay|fps|pos|align|width)| \
5766 -sub@(font-@(blur|outline|autoscale|encoding|@(osd|text)-scale)))
5767 return 0
5768 ;;
5769 -lavdopts)
5770 COMPREPLY=( $( compgen -W 'ec er= bug= idct= gray' \
5771 -- $cur ) )
5772 return 0
5773 ;;
5774 -lavcopts)
5775 COMPREPLY=( $( compgen -W 'vcodec= vqmin= vqscale= \
5776 vqmax= mbqmin= mbqmax= vqdiff= \
5777 vmax_b_frames= vme= vhq v4mv \
5778 keyint= vb_strategy= vpass= \
5779 aspect= vbitrate= vratetol= \
5780 vrc_maxrate= vrc_minrate= \
5781 vrc_buf_size= vb_qfactor= vi_qfactor= \
5782 vb_qoffset= vi_qoffset= vqblur= \
5783 vqcomp= vrc_eq= vrc_override= \
5784 vrc_init_cplx= vqsquish= vlelim= \
5785 vcelim= vstrict= vdpart vpsize= gray \
5786 vfdct= idct= lumi_mask= dark_mask= \
5787 tcplx_mask= scplx_mask= naq ildct \
5788 format= pred qpel precmp= cmp= \
5789 subcmp= predia= dia= trell last_pred= \
5790 preme= subq= psnr mpeg_quant aic umv' \
5791 -- $cur ) )
5792 return 0
5793 ;;
5794 -ssf)
5795 COMPREPLY=( $( compgen -W 'lgb= cgb= ls= cs= chs= \
5796 cvs=' -- $cur ) )
5797 return 0
5798 ;;
5799 -jpeg)
5800 COMPREPLY=( $( compgen -W 'noprogressive progressive \
5801 nobaseline baseline optimize= \
5802 smooth= quality= outdir=' -- $cur ) )
5803 return 0
5804 ;;
5805 -xvidopts)
5806 COMPREPLY=( $( compgen -W 'dr2 nodr2' -- $cur ) )
5807 return 0
5808 ;;
5809 -xvidencopts)
5810 COMPREPLY=( $( compgen -W 'pass= bitrate= \
5811 fixed_quant= me_quality= 4mv \
5812 rc_reaction_delay_factor= \
5813 rc_averaging_period= rc_buffer= \
5814 quant_range= min_key_interval= \
5815 max_key_interval= mpeg_quant \
5816 mod_quant lumi_mask hintedme \
5817 hintfile debug keyframe_boost= \
5818 kfthreshold= kfreduction=' -- $cur ) )
5819 return 0
5820 ;;
5821 -divx4opts)
5822 COMPREPLY=( $( compgen -W 'br= key= deinterlace q= \
5823 min_quant= max_quant= rc_period= \
5824 rc_reaction_period= crispness= \
5825 rc_reaction_ratio= pass= vbrpass= \
5826 help' -- $cur ) )
5827 return 0
5828 ;;
5829 -info)
5830 COMPREPLY=( $( compgen -W 'name= artist= genre= \
5831 subject= copyright= srcform= \
5832 comment= help' -- $cur ) )
5833 return 0
5834 ;;
5835 -lameopts)
5836 COMPREPLY=( $( compgen -W 'vbr= abr cbr br= q= aq= \
5837 ratio= vol= mode= padding= fast \
5838 preset= help' -- $cur ) )
5839 return 0
5840 ;;
5841 -rawaudio)
5842 COMPREPLY=( $( compgen -W 'on channels= rate= \
5843 samplesize= format=' -- $cur ) )
5844 return 0
5845 ;;
5846 -rawvideo)
5847 COMPREPLY=( $( compgen -W 'on fps= sqcif qcif cif \
5848 4cif pal ntsc w= h= y420 yv12 yuy2 \
5849 y8 format= size=' -- $cur ) )
5850 return 0
5851 ;;
5852 -aop)
5853 COMPREPLY=( $( compgen -W 'list= delay= format= fout= \
5854 volume= mul= softclip' -- $cur ) )
5855 return 0
5856 ;;
5857 -dxr2)
5858 COMPREPLY=( $( compgen -W 'ar-mode= iec958-encoded \
5859 iec958-decoded mute ucode= 75ire bw \
5860 color interlaced macrovision= norm= \
5861 square-pixel ccir601-pixel cr-left= \
5862 cr-right= cr-top= cr-bot= ck-rmin= \
5863 ck-gmin= ck-bmin= ck-rmax= ck-gmax= \
5864 ck-bmax= ck-r= ck-g= ck-b= \
5865 ignore-cache= ol-osd= olh-cor= \
5866 olw-cor= olx-cor= oly-cor= overlay \
5867 overlay-ratio= update-cache' -- $cur ))
5868 return 0
5869 ;;
5870 -tv)
5871 COMPREPLY=( $( compgen -W 'on noaudio driver= device= \
5872 input= freq= outfmt= width= height= \
5873 buffersize= norm= channel= chanlist= \
5874 audiorate= forceaudio alsa amode= \
5875 forcechan= adevice= audioid= volume= \
5876 bass= treble= balance= fps= \
5877 channels= immediatemode=' -- $cur ) )
5878 return 0
5879 ;;
5880 -mf)
5881 COMPREPLY=( $( compgen -W 'on w= h= fps= type=' \
5882 -- $cur ) )
5883 return 0
5884 ;;
5885 -cdda)
5886 COMPREPLY=( $( compgen -W 'speed= paranoia= \
5887 generic-dev= sector-size= overlap= \
5888 toc-bias toc-offset= skip noskip' \
5889 -- $cur ) )
5890 return 0
5891 ;;
5892 -input)
5893 COMPREPLY=( $( compgen -W 'conf= ar-delay ar-rate \
5894 keylist cmdlist js-dev file' -- $cur ) )
5895 return 0
5896 ;;
5897 -af)
5898 COMPREPLY=( $( compgen -W 'resample resample= \
5899 channels channels= format format= \
5900 volume volume= delay delay= pan \
5901 pan= sub sub= surround surround=' \
5902 -- $cur ) )
5903 return 0
5904 ;;
5905 -af-adv)
5906 COMPREPLY=( $( compgen -W 'force= list=' -- $cur ) )
5907 return 0
5908 ;;
5909 esac
5910
5911 case "$cur" in
5912 -*)
5913 COMPREPLY=( $( compgen -W '-aid -alang -audio-demuxer \
5914 -audiofile -cdrom-device -cache -cdda \
5915 -channels -chapter -csslib -demuxer \
5916 -dvd -dvd-device -dvdangle -dvdauth \
5917 -dvdkey -dvdnav -forceidx -fps -frames \
5918 -hr-mp3-seek -idx -mc -mf -ni -nobps \
5919 -passwd -rawaudio -rtsp-stream-over-tcp\
5920 -skipopening -sb -srate -ss -tv -user \
5921 -vcd -vid -vivo -ifo -ffactor -font \
5922 -noautosub -nooverlapsub -sid -slang \
5923 -sub -subcc -subcp -sub-demuxer \
5924 -subdelay -subfont-autoscale \
5925 -subfont-blur -subfont-encoding \
5926 -subfont-osd-scale -subfont-outline \
5927 -subfont-text-scale -subfps -subfile \
5928 -subpos -unicode -utf8 -vobsub \
5929 -vobsubid -ac -afm -aspect -flip \
5930 -lavdopts -noaspect -nosound -pp -ssf \
5931 -stereo -sws -vc -vfm -vop -xvidopts\
5932 -xy -zoom -bandwidth -cuefile \
5933 -noextbased -rawvideo -overlapsub \
5934 -sub-bg-alpha -sub-bg-color -subalign \
5935 -subwidth -sub-no-text-pp -spualign \
5936 -spuaa -spugauss -pphelp -verbose -v \
5937 -noni -noidx -nohr-mp3-seek -extbased \
5938 -bps -oldpp -nozoom -noflip -nounicode \
5939 -noutf8' -- $cur ) )
5940 # add mplayer specific options
5941 [[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( "${COMPREPLY[@]}" \
5942 $(compgen -W '-autoq -autosync -benchmark \
5943 -framedrop -h -help -hardframedrop \
5944 -identify -input -lircconf -loop \
5945 -nojoystick -nolirc -nortc -playlist \
5946 -quiet -really-quiet -rnd -sdp -skin \
5947 -slave -softsleep -speed -sstep \
5948 -use-stdin -dumpaudio -dumpfile \
5949 -dumpstream -dumpvideo -dumpmicrodvdsub\
5950 -dumpmpsub -dumpsrtsub -dumpjacosub \
5951 -dumpsami -dumpsub -osdlevel -af \
5952 -af-adv -ao -aofile -aop -delay -mixer \
5953 -nowaveheader -bpp -brightness \
5954 -contrast -display -double -dr -dxr2 \
5955 -fb -fbmode -fbmodeconfig -forcexv -fs \
5956 -geometry -hue -icelayer -jpeg \
5957 -monitor-dotclock -monitor-hfreq \
5958 -monitor-vfreq -monitoraspect \
5959 -nograbpointer -noslices -panscan \
5960 -rootwin -saturation -screenw -screenh \
5961 -stop-xscreensaver -vm -vo -vsync -wid \
5962 -xineramascreen -z -zrbw -zrcrop \
5963 -zrdev -zrfd -zrhelp -zrnorm -zrquality \
5964 -zrvdec -zrhdec -zrxdoff -zrydoff -y \
5965 -edl -edlout -enqueue -fixed-vo \
5966 -menu -menu-root -menu-cfg -shuffle \
5967 -format -aahelp -dfbopts -fstype \
5968 -guiwid -nokeepaspect -x --help \
5969 -aaosdcolor -aasubcolor -aadriver \
5970 -aaextended -aaeight' -- $cur) )
5971 # add mencoder specific options
5972 [[ "$cmd" = mencoder ]] && COMPREPLY=( "${COMPREPLY[@]}" \
5973 $(compgen -W '-audio-density -audio-delay \
5974 -audio-preload -divx4opts -endpos \
5975 -ffourcc -include -info -lameopts \
5976 -lavcopts -noskip -o -oac -ofps -ovc \
5977 -passlogfile -skiplimit -vobsubout \
5978 -vobsuboutindex -vobsuboutid \
5979 -xvidencopts -of --verbose' -- $cur) )
5980 ;;
5981 *)
5982 _filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fli|FLI|flv|FLV|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[34]|MP[34]|m4v|M4V|og[gm]|OG[GM]|wav|WAV|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3gp|mpc|MPC|flac|FLAC|flv|FLV|divx|DIVX)'
5983 ;;
5984 esac
5985
5986 return 0
5987 }
5988 complete $filenames -F _mplayer mplayer mencoder gmplayer kplayer
5989 }
5990
5991 # KDE dcop completion
5992 #
5993 have dcop &&
5994 _dcop()
5995 {
5996 local cur compstr
5997
5998 COMPREPLY=()
5999 cur=`_get_cword`
6000 if [ -z $cur ]; then
6001 compstr=${COMP_WORDS[*]}
6002 else
6003 compstr=$( command echo ${COMP_WORDS[*]} | sed "s/ $cur$//" )
6004 fi
6005 COMPREPLY=( $( compgen -W '$( command $compstr | sed s/\(.*\)// )' -- $cur ) )
6006 } &&
6007 complete -F _dcop dcop
6008
6009 # wvdial(1) completion
6010 #
6011 have wvdial &&
6012 _wvdial()
6013 {
6014 local cur prev config i IFS=$'\t\n'
6015
6016 COMPREPLY=()
6017 cur=`_get_cword`
6018 prev=${COMP_WORDS[COMP_CWORD-1]}
6019
6020 case $prev in
6021 --config)
6022 _filedir
6023 return 0
6024 ;;
6025 esac
6026
6027 case $cur in
6028 -*)
6029 COMPREPLY=( $( compgen -W '--config --chat \
6030 --remotename --help --version --no-syslog' \
6031 -- $cur ) )
6032 ;;
6033 *)
6034 # start with global and personal config files
6035 config="/etc/wvdial.conf"$'\t'"$HOME/.wvdialrc"
6036 # replace with command line config file if present
6037 for (( i=1; i < COMP_CWORD; i++ )); do
6038 if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
6039 config=${COMP_WORDS[i+1]}
6040 break
6041 fi
6042 done
6043 # parse config files for sections and
6044 # remove default section
6045 COMPREPLY=( $( sed -ne \
6046 "s|^\[Dialer \($cur.*\)\]$|\1|p" \
6047 $config 2>/dev/null |grep -v '^Defaults$'))
6048 # escape spaces
6049 COMPREPLY=${COMPREPLY// /\\ }
6050 ;;
6051 esac
6052
6053 } &&
6054 complete -F _wvdial wvdial
6055
6056 # gpg(1) completion
6057 #
6058 have gpg &&
6059 _gpg()
6060 {
6061 local cur prev
6062
6063 COMPREPLY=()
6064 cur=`_get_cword`
6065 prev=${COMP_WORDS[COMP_CWORD-1]}
6066
6067 case "$prev" in
6068 -@(s|-sign|-clearsign|-decrypt-files|-load-extension))
6069 _filedir
6070 return 0
6071 ;;
6072 --@(export|@(?(l|nr|nrl)sign|edit)-key))
6073 # return list of public keys
6074 COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*/\([^ ]*\).*\(<\([^>]*\)>\).*$@\1 \3@p')" -- "$cur" ))
6075 return 0
6076 ;;
6077 -@(r|-recipient))
6078 COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
6079 if [ -e ~/.gnupg/gpg.conf ]; then
6080 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf )" -- "$cur") )
6081 fi
6082 return 0
6083 ;;
6084 esac
6085
6086 if [[ "$cur" == -* ]]; then
6087 COMPREPLY=( $( compgen -W '-s -b -e -f -c -d -a -r -u -Z -o -v\
6088 -q -n -N $(gpg --dump-options)' -- $cur ) )
6089 fi
6090
6091 } &&
6092 complete -F _gpg $default gpg
6093
6094 # iconv(1) completion
6095 #
6096 have iconv &&
6097 _iconv()
6098 {
6099 local cur prev
6100
6101 COMPREPLY=()
6102 cur=`_get_cword`
6103 prev=${COMP_WORDS[COMP_CWORD-1]}
6104
6105 case "$prev" in
6106 -@(f|t|-@(from|to)-code))
6107 COMPREPLY=( $( compgen -W \
6108 '$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ) )
6109 return 0
6110 ;;
6111 esac
6112
6113
6114 if [[ "$cur" = -* ]]; then
6115 COMPREPLY=( $( compgen -W '--from-code -f --to-code -t --list
6116 --output -o --verbose' -- "$cur" ) )
6117 return 0
6118 fi
6119 } &&
6120 complete -F _iconv $default iconv
6121
6122 # dict(1) completion
6123 #
6124 { have dict || have rdict; } && {
6125 _dictdata()
6126 {
6127 dict $host $port $1 2>/dev/null | sed -ne \
6128 's/^['$'\t '']['$'\t '']*\([^'$'\t '']*\).*$/\1/p'
6129 }
6130
6131 _dict()
6132 {
6133 local cur prev host port db dictfile
6134
6135 COMPREPLY=()
6136 cur=`_get_cword`
6137 prev=${COMP_WORDS[COMP_CWORD-1]}
6138 dictfile=/usr/share/dict/words
6139
6140 for (( i=1; i < COMP_CWORD; i++ )); do
6141 case "${COMP_WORDS[i]}" in
6142 -@(h|--host))
6143 host=${COMP_WORDS[i+1]}
6144 [ -n "$host" ] && host="-h $host"
6145 i=$((++i))
6146 ;;
6147 -@(p|-port))
6148 port=${COMP_WORDS[i+1]}
6149 [ -n "$port" ] && port="-p $port"
6150 i=$((++i))
6151 ;;
6152 -@(d|-database))
6153 db=${COMP_WORDS[i+1]}
6154 [ -n "$db" ] && host="-d $db"
6155 i=$((++i))
6156 ;;
6157 *)
6158 ;;
6159 esac
6160 done
6161
6162 if [[ "$cur" = -* ]]; then
6163 COMPREPLY=( $( compgen -W '-h --host -p --port -d --database \
6164 -m --match -s --strategy -c --config -C \
6165 --nocorrect -D --dbs -S --strats -H \
6166 --serverhelp -i --info -I --serverinfo \
6167 -a --noauth -u --user -k --key -V --version \
6168 -L --license --help -v --verbose -r --raw \
6169 -P --pager --debug --html --pipesize --client' \
6170 -- "$cur" ) )
6171 return 0
6172 fi
6173
6174 case "$prev" in
6175 -@(d|-database|i|info))
6176 COMPREPLY=( $( compgen -W '$( _dictdata -D )' -- "$cur" ) )
6177 return 0
6178 ;;
6179 -@(s|-strategy))
6180 COMPREPLY=( $( compgen -W '$( _dictdata -S )' -- "$cur" ) )
6181 return 0
6182 ;;
6183 *)
6184 ;;
6185 esac
6186
6187 [ -r $dictfile ] && \
6188 COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
6189 }
6190 complete -F _dict $default dict rdict
6191 }
6192
6193 # cdrecord(1) completion
6194 #
6195 have cdrecord &&
6196 _cdrecord()
6197 {
6198 local cur prev i generic_options track_options track_mode
6199
6200 COMPREPLY=()
6201 cur=`_get_cword`
6202 prev=${COMP_WORDS[COMP_CWORD-1]}
6203
6204 # foo=bar style option
6205 if [[ "$cur" == *=* ]]; then
6206 prev=${cur/=*/}
6207 cur=${cur/*=/}
6208 case "$prev" in
6209 @(text|cue)file)
6210 _filedir
6211 return 0
6212 ;;
6213 blank)
6214 COMPREPLY=( $( compgen -W 'help all fast \
6215 track unreserve trtail unclose session' \
6216 -- $cur ) )
6217 return 0
6218 ;;
6219 driveropts)
6220 COMPREPLY=( $( compgen -W 'burnfree noburnfree\
6221 varirec= audiomaster forcespeed noforcespeed\
6222 speedread nospeedread singlesession \
6223 nosinglesession hidecdr nohidecdr tattooinfo\
6224 tattoofile=' -- $cur ) )
6225 return 0
6226 ;;
6227 esac
6228 fi
6229
6230 generic_options=(-version -v -V -d -silent -s -force -immed -dummy \
6231 -dao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc \
6232 -atip -fix -nofix -waiti -load -lock -eject -format \
6233 -setdropts -checkdrive -prcap -inq -scanbus -reset \
6234 -abort -overburn -ignsize -useinfo -packet -noclose \
6235 -text debug= kdebug= kd= minbuf= speed= blank= fs= \
6236 dev= gracetime= timeout= driver= driveropts= \
6237 defpregap= pktsize= mcn= textfile= cuefile=)
6238 track_options=(-audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \
6239 -isosize -pad padsize= -nopad -shorttrack -noshorttrack\
6240 pregap= -preemp -nopreemp -copy -nocopy -scms tcsize= \
6241 isrc= index=)
6242 # look if previous was either a file or a track option
6243 track_mode=0
6244 if [ $COMP_CWORD -gt 1 ]; then
6245 if [ -f "$prev" ]; then
6246 track_mode=1
6247 else
6248 for (( i=0; i < ${#track_options[@]}; i++ )); do
6249 if [[ "${track_options[i]}" == "$prev" ]]; then
6250 track_mode=1
6251 break
6252 fi
6253 done
6254 fi
6255 fi
6256
6257 # files are always eligible completion
6258 _filedir
6259 # track options are always available
6260 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '${track_options[@]}' -- $cur ) )
6261 # general options are no more available after file or track option
6262 if [ $track_mode -eq 0 ]; then
6263 COMPREPLY=( "${COMPREPLY[@]}" \
6264 $( compgen -W '${generic_options[@]}' -- $cur ) )
6265 fi
6266
6267 } &&
6268 complete -F _cdrecord $filenames cdrecord
6269
6270 # mkisofs(8) completion
6271 #
6272 have mkisofs &&
6273 _mkisofs()
6274 {
6275 local cur prev
6276
6277 COMPREPLY=()
6278 cur=`_get_cword`
6279 prev=${COMP_WORDS[COMP_CWORD-1]}
6280
6281 case "$prev" in
6282 -@(o|abstract|biblio|check-session|copyright|log-file|root-info|prep-boot|*-list))
6283 _filedir
6284 return 0
6285 ;;
6286 -*-charset)
6287 COMPREPLY=( $( mkisofs -input-charset help 2>&1 | \
6288 tail +3 | grep "^$cur") )
6289 return 0
6290 ;;
6291 -uid)
6292 _uids
6293 return 0
6294 ;;
6295 -gid)
6296 _gids
6297 return 0
6298 ;;
6299 esac
6300
6301 if [[ "$cur" == -* ]]; then
6302 COMPREPLY=( $( compgen -W '-abstract -A -allow-lowercase \
6303 -allow-multidot -biblio -cache-inodes \
6304 -no-cache-inodes -b -eltorito-alt-boot -B -G \
6305 -hard-disk-boot -no-emul-boot -no-boot \
6306 -boot-load-seg -boot-load-size \
6307 -boot-info-table -C -c -check-oldname \
6308 -check-session -copyright -d -D -dir-mode \
6309 -dvd-video -f -file-mode -gid -gui \
6310 -graft-points -hide -hide-list -hidden \
6311 -hidden-list -hide-joliet -hide-joliet-list \
6312 -hide-joliet-trans-tbl -hide-rr-moved \
6313 -input-charset -output-charset -iso-level -J \
6314 -joliet-long -jcharset -l -L -log-file -m \
6315 -exclude-list -max-iso9660-filenames -M -N \
6316 -new-dir-mode -nobak -no-bak -force-rr -no-rr \
6317 -no-split-symlink-components \
6318 -no-split-symlink-fields -o -pad -no-pad \
6319 -path-list -P -p -print-size -quiet -R -r \
6320 -relaxed-filenames -sort -split-output \
6321 -stream-media-size -stream-file-name -sysid -T\
6322 -table-name -ucs-level -udf -uid \
6323 -use-fileversion -U -no-iso-translate -V \
6324 -volset -volset-size -volset-seqno -v -x -z \
6325 -hfs -apple -map -magic -hfs-creator \
6326 -hfs-type -probe -no-desktop -mac-name \
6327 -boot-hfs-file -part -auto -cluster-size \
6328 -hide-hfs -hide-hfs-list -hfs-volid \
6329 -icon-position -root-info -prep-boot \
6330 -input-hfs-charset -output-hfs-charset \
6331 -hfs-unlock -hfs-bless -hfs-parms --cap \
6332 --netatalk --double --ethershare --ushare \
6333 --exchange --sgi --xinet --macbin --single \
6334 --dave --sfm --osx-double --osx-hfs' -- $cur ))
6335 else
6336 _filedir
6337 fi
6338
6339 } &&
6340 complete -F _mkisofs $filenames mkisofs
6341
6342 # mc(1) completion
6343 #
6344 have mc &&
6345 _mc()
6346 {
6347 local cur prev
6348
6349 COMPREPLY=()
6350 cur=`_get_cword`
6351 prev=${COMP_WORDS[COMP_CWORD-1]}
6352
6353 # -name value style option
6354 case "$prev" in
6355 -@(e|v|l|P))
6356 _filedir
6357 return 0
6358 ;;
6359 esac
6360
6361 # --name=value style option
6362 if [[ "$cur" == *=* ]]; then
6363 prev=${cur/=*/}
6364 cur=${cur/*=/}
6365 case "$prev" in
6366 --@(edit|view|ftplog|printwd))
6367 _filedir
6368 return 0
6369 ;;
6370 esac
6371 fi
6372
6373 if [[ "$cur" == -* ]]; then
6374 COMPREPLY=( $( compgen -W '-a --stickchars -b --nocolor -c \
6375 --color -C --colors= -d --nomouse -e --edit= -f \
6376 --datadir -k --resetsoft -l --ftplog= -P --printwd= \
6377 -s --slow -t --termcap -u --nosubshell -U --subshell \
6378 -v --view= -V --version -x --xterm -h --help' -- $cur ) )
6379 else
6380 _filedir -d
6381 fi
6382 } &&
6383 complete -F _mc $filenames mc
6384
6385 # yum(8) completion
6386 #
6387 have yum && {
6388 _yum()
6389 {
6390 local cur prev special
6391
6392 COMPREPLY=()
6393 cur=`_get_cword`
6394 prev=${COMP_WORDS[COMP_CWORD-1]}
6395
6396 for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
6397 if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist) ]]; then
6398 special=${COMP_WORDS[i]}
6399 fi
6400 done
6401
6402 if [ -n "$special" ]; then
6403 case $special in
6404 install|deplist)
6405 COMPREPLY=( $( compgen -W '$( yum -C list | cut -d" " -f1 )' -- $cur ) )
6406 return 0
6407 ;;
6408 *)
6409 _rpm_installed_packages
6410 return 0
6411 ;;
6412 esac
6413 fi
6414
6415 case $cur in
6416 --*)
6417 COMPREPLY=( $( compgen -W '--installroot --version --help --enablerepo --disablerepo --exclude --obsoletes --noplugins' -- $cur ) )
6418 return 0
6419 ;;
6420 -*)
6421 COMPREPLY=( $( compgen -W '-c -e -d -y -t -R -C -h' -- $cur ) )
6422 return 0
6423 ;;
6424 esac
6425
6426 case $prev in
6427 list)
6428 COMPREPLY=( $( compgen -W 'all available updates installed extras obsoletes recent' -- $cur ) )
6429 ;;
6430 clean)
6431 COMPREPLY=( $( compgen -W 'packages headers metadata cache dbcache all' -- $cur ) )
6432 ;;
6433 localinstall)
6434 _filedir rpm
6435 ;;
6436 -c)
6437 _filedir
6438 ;;
6439 --installroot)
6440 _filedir -d
6441 ;;
6442 *)
6443 COMPREPLY=( $( compgen -W 'install update check-update upgrade remove list \
6444 search info provides clean groupinstall groupupdate \
6445 grouplist deplist erase groupinfo groupremove \
6446 localinstall localupdate makecache resolvedep \
6447 shell whatprovides' -- $cur ) )
6448 ;;
6449 esac
6450 }
6451 complete -F _yum $filenames yum
6452
6453 # yum-arch(8) completion
6454 #
6455 _yum_arch()
6456 {
6457 local cur
6458 COMPREPLY=()
6459 cur=`_get_cword`
6460
6461 case "$cur" in
6462 -*)
6463 COMPREPLY=( $( compgen -W '-d -v -vv -n -c -z -s -l -q' -- $cur ) )
6464 ;;
6465 *)
6466 _filedir -d
6467 ;;
6468 esac
6469
6470 return 0
6471
6472 }
6473 complete -F _yum_arch $filenames yum-arch
6474 }
6475
6476 # ImageMagick completion
6477 #
6478 have convert && {
6479 _ImageMagick()
6480 {
6481 local prev
6482 prev=${COMP_WORDS[COMP_CWORD-1]}
6483
6484 case "$prev" in
6485 -channel)
6486 COMPREPLY=( $( compgen -W 'Red Green Blue Opacity \
6487 Matte Cyan Magenta Yellow Black' -- $cur ) )
6488 return 0
6489 ;;
6490 -colormap)
6491 COMPREPLY=( $( compgen -W 'shared private' -- $cur ) )
6492 return 0
6493 ;;
6494 -colorspace)
6495 COMPREPLY=( $( compgen -W 'GRAY OHTA RGB Transparent \
6496 XYZ YCbCr YIQ YPbPr YUV CMYK' -- $cur ) )
6497 return 0
6498 ;;
6499 -compose)
6500 COMPREPLY=( $( compgen -W 'Over In Out Atop Xor Plus \
6501 Minus Add Subtract Difference Multiply Bumpmap\
6502 Copy CopyRed CopyGreen CopyBlue CopyOpacity' \
6503 -- $cur ) )
6504 return 0
6505 ;;
6506 -compress)
6507 COMPREPLY=( $( compgen -W 'None BZip Fax Group4 JPEG \
6508 Lossless LZW RLE Zip' -- $cur ) )
6509 return 0
6510 ;;
6511 -dispose)
6512 COMPREPLY=( $( compgen -W 'Undefined None Background \
6513 Previous' -- $cur ) )
6514 return 0
6515 ;;
6516 -encoding)
6517 COMPREPLY=( $( compgen -W 'AdobeCustom AdobeExpert \
6518 AdobeStandard AppleRoman BIG5 GB2312 Latin2 \
6519 None SJIScode Symbol Unicode Wansung' -- $cur))
6520 return 0
6521 ;;
6522 -endian)
6523 COMPREPLY=( $( compgen -W 'MSB LSB' -- $cur ) )
6524 return 0
6525 ;;
6526 -filter)
6527 COMPREPLY=( $( compgen -W 'Point Box Triangle Hermite \
6528 Hanning Hamming Blackman Gaussian Quadratic \
6529 Cubic Catrom Mitchell Lanczos Bessel Sinc' \
6530 -- $cur ) )
6531 return 0
6532 ;;
6533 -format)
6534 COMPREPLY=( $( convert -list format | \
6535 awk '/ [r-][w-][+-] / {print $1}' | \
6536 tr -d '*' | tr [:upper:] [:lower:] | \
6537 grep "^$cur" ) )
6538 return 0
6539 ;;
6540 -gravity)
6541 COMPREPLY=( $( compgen -W 'Northwest North NorthEast \
6542 West Center East SouthWest South SouthEast' \
6543 -- $cur ) )
6544 return 0
6545 ;;
6546 -intent)
6547 COMPREPLY=( $( compgen -W 'Absolute Perceptual \
6548 Relative Saturation' -- $cur ) )
6549 return 0
6550 ;;
6551 -interlace)
6552 COMPREPLY=( $( compgen -W 'None Line Plane Partition' \
6553 -- $cur ) )
6554 return 0
6555 ;;
6556 -limit)
6557 COMPREPLY=( $( compgen -W 'Disk File Map Memory' \
6558 -- $cur ) )
6559 return 0
6560 ;;
6561 -list)
6562 COMPREPLY=( $( compgen -W 'Delegate Format Magic \
6563 Module Resource Type' -- $cur ) )
6564 return 0
6565 ;;
6566 -map)
6567 COMPREPLY=( $( compgen -W 'best default gray red \
6568 green blue' -- $cur ) )
6569 _filedir
6570 return 0
6571 ;;
6572 -noise)
6573 COMPREPLY=( $( compgen -W 'Uniform Gaussian \
6574 Multiplicative \
6575 Impulse Laplacian Poisson' -- $cur ) )
6576 return 0
6577 ;;
6578 -preview)
6579 COMPREPLY=( $( compgen -W 'Rotate Shear Roll Hue \
6580 Saturation Brightness Gamma Spiff \
6581 Dull Grayscale Quantize Despeckle \
6582 ReduceNoise AddNoise Sharpen Blur \
6583 Treshold EdgeDetect Spread Shade \
6584 Raise Segment Solarize Swirl Implode \
6585 Wave OilPaint CharcoalDrawing JPEG' \
6586 -- $cur ) )
6587 return 0
6588 ;;
6589 -@(mask|profile|texture|tile|write))
6590 _filedir
6591 return 0
6592 ;;
6593 -type)
6594 COMPREPLY=( $( compgen -W 'Bilevel Grayscale Palette \
6595 PaletteMatte TrueColor TrueColorMatte \
6596 ColorSeparation ColorSeparationlMatte \
6597 Optimize' -- $cur ) )
6598 return 0
6599 ;;
6600 -units)
6601 COMPREPLY=( $( compgen -W 'Undefined PixelsPerInch \
6602 PixelsPerCentimeter' -- $cur ) )
6603 return 0
6604 ;;
6605 -virtual-pixel)
6606 COMPREPLY=( $( compgen -W 'Constant Edge mirror tile' \
6607 -- $cur ) )
6608 return 0
6609 ;;
6610 -visual)
6611 COMPREPLY=( $( compgen -W 'StaticGray GrayScale \
6612 StaticColor PseudoColor TrueColor \
6613 DirectColor defaut visualid' -- $cur ))
6614 return 0
6615 ;;
6616 esac
6617 }
6618
6619 _convert()
6620 {
6621 local cur
6622
6623 COMPREPLY=()
6624 cur=`_get_cword`
6625
6626 _ImageMagick
6627
6628 if [[ "$cur" == -* ]]; then
6629 COMPREPLY=( $( compgen -W '-adjoin -affine -antialias -append \
6630 -authenticate -average -background -black-threshold \
6631 -blue-primary -blur -border -bordercolor -channel \
6632 -charcoal -chop -clip -coalesce -colorize -colors \
6633 -colorspace -comment -compress -contrast -convolve \
6634 -crop -cycle -debug -deconstruct -delay -density \
6635 -depth -despeckle -display -dispose -dither -draw \
6636 -edge -emboss -encoding -endian -enhance -equalize \
6637 -extract -fill -filter -flatten -flip -flop -font \
6638 -frame -fuzz -gamma -gaussian -geometry \
6639 -green-primary -gravity -help -implode -intent \
6640 -interlace -label -lat -level -limit -list -log -loop \
6641 -map -mask -matte -median -modulate -monochrome \
6642 -morph -mosaic -negate -noop -noise -normalize \
6643 -opaque -ordered-dither -page -paint -ping -pointsize \
6644 -preview -profile -quality -raise -random-threshold \
6645 -region -raise -red-primary -render -resize -resample \
6646 -roll -rotate -sample -sampling-factor -scale -scene \
6647 -seed -segment -shade -sharpen -shave -shear -size \
6648 -solarize -spread -stroke -strokewidth -swirl \
6649 -texture -threshold -thumbnail -tile -transform \
6650 -transparent -treedepth -trim -type -undercolor \
6651 -units -unsharp -verbose -version -view \
6652 -virtual-pixel -wave -white-point -white-threshold \
6653 -write' -- $cur ) )
6654 elif [[ "$cur" == +* ]]; then
6655 COMPREPLY=( $( compgen -W '+adjoin +append +compress \
6656 +contrast +debug +dither +endian +gamma +label +map \
6657 +mask +matte +negate +noise +page +raise +render \
6658 +write' -- $cur ) )
6659 else
6660 _filedir
6661 fi
6662 }
6663 complete -F _convert $filenames convert
6664
6665 _mogrify()
6666 {
6667 local cur
6668
6669 COMPREPLY=()
6670 cur=`_get_cword`
6671
6672 _ImageMagick
6673
6674 if [[ "$cur" == -* ]]; then
6675 COMPREPLY=( $( compgen -W '-affine -antialias -authenticate \
6676 -background -black-threshold -blue-primary -blur \
6677 -border -bordercolor -channel -charcoal -chop \
6678 -colorize -colors -colorspace -comment -compress \
6679 -contrast -convolve -crop -cycle -debug -delay \
6680 -density -depth -despeckle -display -dispose -dither \
6681 -draw -edge -emboss -encoding -endian -enhance \
6682 -equalize -extract -fill -filter -flip -flop -font \
6683 -format -frame -fuzz -gamma -gaussian -geometry \
6684 -green-primary -implode -interlace -help -label -lat \
6685 -level -limit -list -log -loop -map -mask -matte \
6686 -median -modulate -monochrome -negate -noop \
6687 -normalize -opaque -page -paint -fill -ordered-dither \
6688 -pointsize -profile -quality -raise -random-threshold \
6689 -red-primary -region -resample -resize -roll -rotate \
6690 -sample -sampling-factor -scale -scene -seed -segment \
6691 -shade -sharpen -shear -size -solarize -spread \
6692 -stroke -strokewidth -swirl -texture -threshold \
6693 -thumbnail -tile -transform -transparent -treedepth \
6694 -trim -type -undercolor -units -unsharp -verbose \
6695 -version -view -virtual-pixel -wave -white-point \
6696 -white-threshold' -- $cur ) )
6697 elif [[ "$cur" == +* ]]; then
6698 COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
6699 +endian +gamma +label +map +mask +matte +negate +page \
6700 +raise' -- $cur ) )
6701 else
6702 _filedir
6703 fi
6704 }
6705 complete -F _mogrify $filenames mogrify
6706
6707 _display()
6708 {
6709 local cur
6710
6711 COMPREPLY=()
6712 cur=`_get_cword`
6713
6714 _ImageMagick
6715
6716 if [[ "$cur" == -* ]]; then
6717 COMPREPLY=( $( compgen -W '-authenticate -backdrop -border \
6718 -colormap -colors -colorspace -comment -compress \
6719 -contrast -crop -debug -delay -density -depth \
6720 -despeckle -display -dispose -dither -edge -endian \
6721 -enhance -extract -filter -flip -flop -frame -gamma \
6722 -geometry -help -immutable -interlace -label -limit \
6723 -log -map -matte -monochrome -negate -noop -page \
6724 -quality -raise -remote -roll -rotate -sample \
6725 -sampling-factor -scene -segment -sharpen -size \
6726 -texture -treedepth -trim -update -verbose -version \
6727 -virtual-pixel -window -window_group -write' -- $cur))
6728 elif [[ "$cur" == +* ]]; then
6729 COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
6730 +endian +gamma +label +map +matte +negate +page \
6731 +raise +write' -- $cur ) )
6732 else
6733 _filedir
6734 fi
6735 }
6736 complete -F _display $filenames display
6737
6738 _animate()
6739 {
6740 local cur
6741
6742 COMPREPLY=()
6743 cur=`_get_cword`
6744
6745 _ImageMagick
6746
6747 if [[ "$cur" == -* ]]; then
6748 COMPREPLY=( $( compgen -W '-authenticate -backdrop -colormap \
6749 -colors -colorspace -crop -debug -delay -density \
6750 -depth -display -dither -extract -gamma -geometry \
6751 -help -interlace -limit -log -matte -map -monochrome \
6752 -noop -pause -remote -rotate -sampling-factor -scene \
6753 -size -treedepth -trim -verbose -version -visual \
6754 -virtual-pixel -window' -- $cur ) )
6755 elif [[ "$cur" == +* ]]; then
6756 COMPREPLY=( $( compgen -W '+debug +dither +gamma +map +matte' -- $cur ) )
6757 else
6758 _filedir
6759 fi
6760 }
6761 complete -F _animate $filenames animate
6762
6763 _identify()
6764 {
6765 local cur
6766
6767 COMPREPLY=()
6768 cur=`_get_cword`
6769
6770 _ImageMagick
6771
6772 if [[ "$cur" == -* ]]; then
6773 COMPREPLY=( $( compgen -W '-authenticate -debug -density \
6774 -depth -extract -format -help -interlace -limit -list \
6775 -log -size -sampling-factor -verbose -version \
6776 -virtual-pixel' -- $cur ) )
6777 elif [[ "$cur" == +* ]]; then
6778 COMPREPLY=( $( compgen -W '+debug ' -- $cur ) )
6779 else
6780 _filedir
6781 fi
6782 }
6783 complete -F _identify $filenames identify
6784
6785 _montage()
6786 {
6787 local cur
6788
6789 COMPREPLY=()
6790 cur=`_get_cword`
6791
6792 _ImageMagick
6793
6794 if [[ "$cur" == -* ]]; then
6795 COMPREPLY=( $( compgen -W '-adjoin -affine -authenticate \
6796 -blue-primary -blur -colors -colorspace -comment \
6797 -compose -compress -crop -debug -density -depth \
6798 -display -dispose -dither -draw -encoding -endian \
6799 -extract -fill -filter -flip -flop -frame -gamma \
6800 -geometry -gravity -green-primary -interlace -help \
6801 -label -limit -log -matte -mode -monochrome -noop \
6802 -page -pointsize -quality -red-primary -resize \
6803 -rotate -sampling-factor -scene -shadow -size \
6804 -stroke -texture -thumbnail -tile -transform \
6805 -transparent -treedepth -trim -type -verbose \
6806 -version -virtual-pixel -white-point' -- $cur ) )
6807 elif [[ "$cur" == +* ]]; then
6808 COMPREPLY=( $( compgen -W '+adjoin +compress +debug +dither \
6809 +endian +gamma +label +matte +page' -- $cur ) )
6810 else
6811 _filedir
6812 fi
6813 }
6814 complete -F _montage $filenames montage
6815
6816 _composite()
6817 {
6818 local cur
6819
6820 COMPREPLY=()
6821 cur=`_get_cword`
6822
6823 _ImageMagick
6824
6825 if [[ "$cur" == -* ]]; then
6826 COMPREPLY=( $( compgen -W '-affine -authenticate \
6827 -blue-primary -colors -colorspace -comment -compose \
6828 -compress -debug -density -depth -displace -display \
6829 -dispose -dissolve -dither -encoding -endian -extract \
6830 -filter -font -geometry -gravity -green-primary -help \
6831 -interlace -label -limit -log -matte -monochrome \
6832 -negate -page -profile -quality -red-primary -rotate \
6833 -resize -sampling-factor -scene -sharpen -size \
6834 -stegano -stereo -thumbnail -tile -transform \
6835 -treedepth -type -units -unsharp -verbose -version \
6836 -virtual-pixel -watermark -white-point -write' \
6837 -- $cur ) )
6838 elif [[ "$cur" == +* ]]; then
6839 COMPREPLY=( $( compgen -W '+compress +debug +dither +endian +label \
6840 +matte +negate +page +write' -- $cur ) )
6841 else
6842 _filedir
6843 fi
6844 }
6845 complete -F _composite $filenames composite
6846 }
6847
6848 # dd(1) completion
6849 #
6850 have dd &&
6851 _dd()
6852 {
6853 local cur
6854
6855 COMPREPLY=()
6856 cur=`_get_cword`
6857
6858 case "$cur" in
6859 if=*|of=*)
6860 cur=${cur#*=}
6861 _filedir
6862 return 0
6863 ;;
6864 conv=*)
6865 cur=${cur#*=}
6866 COMPREPLY=( $( compgen -W 'ascii ebcdic ibm block unblock \
6867 lcase notrunc ucase swab noerror sync' \
6868 -- $cur ) )
6869 return 0
6870 ;;
6871 esac
6872
6873 _expand || return 0
6874
6875 COMPREPLY=( $( compgen -W '--help --version' -- $cur ) \
6876 $( compgen -W 'bs cbs conv count ibs if obs of seek skip'\
6877 -S '=' -- $cur ) )
6878 } &&
6879 complete -F _dd $nospace $filenames dd
6880
6881 # CUPS cancel(1) completion
6882 #
6883 have cancel &&
6884 _cancel()
6885 {
6886 local cur
6887
6888 COMPREPLY=()
6889 cur=`_get_cword`
6890
6891 COMPREPLY=( $( lpstat | cut -d' ' -f1 | grep "^$cur" ) )
6892 } &&
6893 complete -F _cancel $filenames cancel
6894
6895 # aspell(1) completion
6896 #
6897 have aspell && {
6898 _aspell_dictionary()
6899 {
6900 local datadir
6901 datadir=/usr/lib/aspell
6902 COMPREPLY=( $( command ls $datadir/*.@(multi|alias) ) )
6903 COMPREPLY=( ${COMPREPLY[@]%.@(multi|alias)} )
6904 COMPREPLY=( $( compgen -W '${COMPREPLY[@]#$datadir/}' -- $cur ) )
6905 }
6906
6907 _aspell()
6908 {
6909 local cur prev
6910
6911 COMPREPLY=()
6912 cur=`_get_cword`
6913 prev=${COMP_WORDS[COMP_CWORD-1]}
6914
6915 # --name value style option
6916 case "$prev" in
6917 @(-c|-p|check))
6918 _filedir
6919 return 0
6920 ;;
6921 @(dump|create|merge))
6922 COMPREPLY=( $( compgen -W 'master personal repl' -- $cur ) )
6923 return 0
6924 ;;
6925 -d)
6926 _aspell_dictionary
6927 return 0
6928 ;;
6929 esac
6930
6931 # --name=value style option
6932 if [[ "$cur" == *=* ]]; then
6933 prev=${cur/=*/}
6934 cur=${cur/*=/}
6935 case "$prev" in
6936 --@(conf|personal|repl|per-conf))
6937 _filedir
6938 return 0
6939 ;;
6940 --@(conf-dir|data-dir|dict-dir|home-dir|local-data-dir|prefix))
6941 _filedir -d
6942 return 0
6943 ;;
6944 --master)
6945 _aspell_dictionary
6946 return 0
6947 ;;
6948 --mode)
6949 COMPREPLY=( $( compgen -W 'none url email sgml tex' -- $cur ) )
6950 return 0
6951 ;;
6952 --sug-mode)
6953 COMPREPLY=( $( compgen -W 'ultra fast normal bad-speller' -- $cur ) )
6954 return 0
6955 ;;
6956 --keymapping)
6957 COMPREPLY=( $( compgen -W 'aspell ispell' -- $cur ) )
6958 return 0
6959 ;;
6960 esac
6961 fi
6962
6963 if [[ "$cur" == -* ]]; then
6964 COMPREPLY=( $( compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= \
6965 --encoding= --add-filter= --rem-filter= --mode= -e \
6966 -H -t --add-extra-dicts= --rem-extra-dicts= \
6967 --home-dir= -W --ignore= --ignore-accents \
6968 --dont-ignore-accents --ignore-case --dont-ignore-case \
6969 --ignore-repl --dont-ignore-repl --jargon= --keyboard= \
6970 --lang= --language-tag= --local-data-dir= -d --master= \
6971 --module= --add-module-search-order= \
6972 --rem-module-search-order= --per-conf= -p --personal= \
6973 --prefix= --repl= -C -B --run-together --dont-run-together \
6974 --run-together-limit= --run-together-min= --save-repl \
6975 --dont-save-repl --set-prefix --dont-set-prefix --size= \
6976 --spelling= --strip-accents --dont-strip-accents \
6977 --sug-mode= --add-word-list-path= --rem-word-list-path= \
6978 -b -x --backup -b|-x --dont-backup --reverse --dont-reverse \
6979 --time --dont-time --keymapping= --add-email-quote= \
6980 --rem-email-quote= --email-margin= --add-tex-command= \
6981 --rem-tex-command= --tex-check-comments \
6982 --dont-tex-check-comments --add-tex-extension= \
6983 --rem-tex-extension= --add-sgml-check= --rem-sgml-check= \
6984 --add-sgml-extension= --rem-sgml-extension=' -- $cur ) )
6985 else
6986 COMPREPLY=( $( compgen -W '-? help -c check -a pipe -l list \
6987 config config soundslike filter -v version dump \
6988 create merge' -- $cur ) )
6989 fi
6990
6991 }
6992 complete -F _aspell $filenames aspell
6993 }
6994
6995 # xmms(1) completion
6996 #
6997 have xmms &&
6998 _xmms()
6999 {
7000 local cur
7001
7002 COMPREPLY=()
7003 cur=`_get_cword`
7004
7005 if [[ "$cur" == -* ]]; then
7006 COMPREPLY=( $( compgen -W '-h --help -r --rew -p --play \
7007 -u --pause -s --stop -t --play-pause -f --fwd -e \
7008 --enqueue -m --show-main-window -i --sm-client-id \
7009 -v --version' -- $cur ) )
7010 else
7011 _filedir '@(mp[23]|MP[23]|ogg|OGG|wav|WAV|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)'
7012
7013 fi
7014
7015 } &&
7016 complete -F _xmms $filenames xmms
7017
7018 # info(1) completion
7019 #
7020 have info &&
7021 _info()
7022 {
7023 local cur infopath UNAME
7024
7025 COMPREPLY=()
7026 cur=`_get_cword`
7027
7028 _expand || return 0
7029
7030 # default completion if parameter contains /
7031 if [[ "$cur" == */* ]]; then
7032 _filedir
7033 return 0
7034 fi
7035
7036 infopath='/usr/share/info'
7037
7038 if [ "${INFOPATH: -1:1}" == ':' ]; then
7039 infopath=${INFOPATH}${infopath}
7040 elif [ ${INFOPATH:+set} ]; then
7041 infopath=$INFOPATH
7042 fi
7043
7044 infopath=$infopath:
7045 if [ -n "$cur" ]; then
7046 infopath="${infopath//://$cur* }"
7047 else
7048 infopath="${infopath//:// }"
7049 fi
7050
7051 # redirect stderr for when path doesn't exist
7052 COMPREPLY=( $( eval command ls "$infopath" 2>/dev/null ) )
7053 # weed out directory path names and paths to info pages
7054 COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
7055 # weed out info dir file
7056 for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do
7057 if [ "${COMPREPLY[$i]}" == 'dir' ]; then
7058 unset COMPREPLY[$i];
7059 fi;
7060 done
7061 # strip suffix from info pages
7062 COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2)} )
7063 COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
7064
7065 return 0
7066 } &&
7067 complete -F _info $filenames info
7068
7069 # dhclient(1) completion
7070 #
7071 have dhclient && _dhclient()
7072 {
7073 local cur prev
7074
7075 COMPREPLY=()
7076 cur=`_get_cword`
7077 prev=${COMP_WORDS[COMP_CWORD-1]}
7078
7079 case "$prev" in
7080 -@(cf|lf|pf|sf))
7081 _filedir
7082 return 0
7083 ;;
7084 -s)
7085 _known_hosts
7086 return 0
7087 ;;
7088 esac
7089
7090 if [[ "$cur" == -* ]]; then
7091 COMPREPLY=( $( compgen -W '-p -d -q -1 -r -lf -pf \
7092 -cf -sf -s -g -n -nw -w' -- $cur ) )
7093 else
7094 _available_interfaces
7095 fi
7096 } &&
7097 complete -F _dhclient dhclient
7098
7099 # lvm(8) completion
7100 #
7101 have lvm && {
7102 _volumegroups()
7103 {
7104 COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \
7105 sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- $cur ) )
7106 }
7107
7108 _physicalvolumes()
7109 {
7110 COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \
7111 sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- $cur ) )
7112 }
7113
7114 _logicalvolumes()
7115 {
7116 COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \
7117 sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- $cur ) )
7118 }
7119
7120 _units()
7121 {
7122 COMPREPLY=( $( compgen -W 'h s b k m g t H K M G T' -- $cur ) )
7123 }
7124
7125 _sizes()
7126 {
7127 COMPREPLY=( $( compgen -W 'k K m M g G t T' -- $cur ) )
7128 }
7129
7130 _args()
7131 {
7132 args=0
7133 if [[ "${COMP_WORDS[0]}" == lvm ]]; then
7134 offset=2
7135 else
7136 offset=1
7137 fi
7138 for (( i=$offset; i < COMP_CWORD; i++ )); do
7139 if [[ "${COMP_WORDS[i]}" != -* ]]; then
7140 args=$(($args + 1))
7141 fi
7142 done
7143 }
7144
7145 _lvmdiskscan()
7146 {
7147 local cur
7148
7149 COMPREPLY=()
7150 cur=`_get_cword`
7151
7152 if [[ "$cur" == -* ]]; then
7153 COMPREPLY=( $( compgen -W '-d --debug -h -? --help -l \
7154 --lvmpartition -v --verbose --version' -- $cur ) )
7155 fi
7156 }
7157 complete -F _lvmdiskscan lvmdiskscan
7158
7159 _pvscan()
7160 {
7161 local cur
7162
7163 COMPREPLY=()
7164 cur=`_get_cword`
7165
7166 if [[ "$cur" == -* ]]; then
7167 COMPREPLY=( $( compgen -W '-d --debug -e \
7168 --exported -n --novolumegroup -h -? \
7169 --help --ignorelockingfailure -P \
7170 --partial -s --short -u --uuid -v \
7171 --verbose --version' -- $cur ) )
7172 fi
7173 }
7174 complete -F _pvscan pvscan
7175
7176 _pvs()
7177 {
7178 local cur prev
7179
7180 COMPREPLY=()
7181 cur=`_get_cword`
7182 prev=${COMP_WORDS[COMP_CWORD-1]}
7183
7184 case "$prev" in
7185 -@(o|O|-options|-sort))
7186 COMPREPLY=( $( compgen -W 'pv_fmt pv_uuid \
7187 pv_size pv_free pv_used pv_name \
7188 pv_attr pv_pe_count \
7189 pv_pe_alloc_count' -- $cur ) )
7190 return 0
7191 ;;
7192 --units)
7193 _units
7194 return 0
7195 ;;
7196 esac
7197
7198 if [[ "$cur" == -* ]]; then
7199 COMPREPLY=( $( compgen -W '--aligned -a --all -d --debug \
7200 -h -? --help --ignorelockingfailure --noheadings \
7201 --nosuffix -o --options -O --sort \
7202 --separator --unbuffered --units \
7203 -v --verbose --version' -- $cur ) )
7204 else
7205 _physicalvolumes
7206 fi
7207 }
7208 complete -F _pvs pvs
7209
7210 _pvdisplay()
7211 {
7212 local cur prev
7213
7214 COMPREPLY=()
7215 cur=`_get_cword`
7216 prev=${COMP_WORDS[COMP_CWORD-1]}
7217
7218 case "$prev" in
7219 --units)
7220 _units
7221 return 0
7222 ;;
7223 esac
7224
7225 if [[ "$cur" == -* ]]; then
7226 COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
7227 -v --verbose -d --debug -h --help --version' -- $cur ) )
7228 else
7229 _physicalvolumes
7230 fi
7231 }
7232 complete -F _pvdisplay pvdisplay
7233
7234 _pvchange()
7235 {
7236 local cur prev
7237
7238 COMPREPLY=()
7239 cur=`_get_cword`
7240 prev=${COMP_WORDS[COMP_CWORD-1]}
7241
7242 case "$prev" in
7243 -@(A|x|-autobackup|--allocatable))
7244 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7245 return 0
7246 ;;
7247 esac
7248
7249 if [[ "$cur" == -* ]]; then
7250 COMPREPLY=( $( compgen -W '-a --all -A --autobackup \
7251 -d --debug -h --help -t --test -u --uuid -x \
7252 --allocatable -v --verbose --addtag --deltag \
7253 --version' -- $cur ) )
7254 else
7255 _physicalvolumes
7256 fi
7257 }
7258 complete -F _pvchange pvchange
7259
7260 _pvcreate()
7261 {
7262 local cur prev
7263
7264 COMPREPLY=()
7265 cur=`_get_cword`
7266 prev=${COMP_WORDS[COMP_CWORD-1]}
7267
7268 case "$prev" in
7269 --restorefile)
7270 _filedir
7271 return 0
7272 ;;
7273 -@(M|-metadatatype))
7274 COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
7275 return 0
7276 ;;
7277 --metadatacopies)
7278 COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) )
7279 return 0
7280 ;;
7281 --@(metadatasize|setphysicalvolumesize))
7282 _sizes
7283 return 0
7284 ;;
7285 esac
7286
7287 if [[ "$cur" == -* ]]; then
7288 COMPREPLY=( $( compgen -W '--restorefile -d --debug -f \
7289 --force -h -? --help --labelsector -M --metadatatype \
7290 --metadatacopies --metadatasize \
7291 --setphysicalvolumesize -t --test -u --uuid uuid -v \
7292 --verbose -y --yes --version' -- $cur ) )
7293 else
7294 _physicalvolumes
7295 fi
7296 }
7297 complete -F _pvcreate pvcreate
7298
7299 _pvmove()
7300 {
7301 local cur prev
7302
7303 COMPREPLY=()
7304 cur=`_get_cword`
7305 prev=${COMP_WORDS[COMP_CWORD-1]}
7306
7307 case "$prev" in
7308 -@(A|-autobackup))
7309 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7310 return 0
7311 ;;
7312 -@(n|-name))
7313 _logicalvolumes
7314 return 0
7315 esac
7316
7317 if [[ "$cur" == -* ]]; then
7318 COMPREPLY=( $( compgen -W '--abort -A --autobackup \
7319 -b --background -d --debug -f --force -h -? \
7320 --help -i --interval -t --test -v --verbose \
7321 --version -n --name' -- $cur ) )
7322 else
7323 _physicalvolumes
7324 fi
7325 }
7326 complete -F _pvmove pvmove
7327
7328 _pvremove()
7329 {
7330 local cur
7331
7332 COMPREPLY=()
7333 cur=`_get_cword`
7334
7335 if [[ "$cur" == -* ]]; then
7336 COMPREPLY=( $( compgen -W '-d --debug -f --force -h -? \
7337 --help -y --yes -t --test -v --verbose \
7338 --version' -- $cur ) )
7339 else
7340 _physicalvolumes
7341 fi
7342 }
7343 complete -F _pvremove pvremove
7344
7345 _vgscan()
7346 {
7347 local cur
7348
7349 COMPREPLY=()
7350 cur=`_get_cword`
7351
7352 if [[ "$cur" == -* ]]; then
7353 COMPREPLY=( $( compgen -W '-d --debug -h --help \
7354 --ignorelockingfailure --mknodes -P \
7355 --partial -v --verbose --version' -- $cur ) )
7356 fi
7357 }
7358 complete -F _vgscan vgscan
7359
7360 _vgs()
7361 {
7362 local cur prev
7363
7364 COMPREPLY=()
7365 cur=`_get_cword`
7366 prev=${COMP_WORDS[COMP_CWORD-1]}
7367
7368 case "$prev" in
7369 -@(o|O|-options|-sort))
7370 COMPREPLY=( $( compgen -W 'vg_fmt vg_uuid vg_name \
7371 vg_attr vg_size vg_free vg_sysid \
7372 vg_extent_size vg_extent_count vg_free_count \
7373 max_lv max_pv pv_count lv_count snap_count \
7374 vg_seqno' -- $cur ) )
7375 return 0
7376 ;;
7377 --units)
7378 _units
7379 return 0
7380 ;;
7381 esac
7382
7383 if [[ "$cur" == -* ]]; then
7384 COMPREPLY=( $( compgen -W '--aligned -d --debug \
7385 -h --help --ignorelockingfailure --noheadings \
7386 --nosuffix -o --options -O --sort -P --partial \
7387 --separator --unbuffered --units \
7388 -v --verbose --version' -- $cur ) )
7389 else
7390 _volumegroups
7391 fi
7392 }
7393 complete -F _vgs vgs
7394
7395 _vgdisplay()
7396 {
7397 local cur prev
7398
7399 COMPREPLY=()
7400 cur=`_get_cword`
7401 prev=${COMP_WORDS[COMP_CWORD-1]}
7402
7403 case "$prev" in
7404 --units)
7405 _units
7406 return 0
7407 ;;
7408 esac
7409
7410 if [[ "$cur" == -* ]]; then
7411 COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
7412 -P --partial -A --activevolumegroups -v --verbose \
7413 -d --debug -h --help --version' -- $cur ) )
7414 else
7415 _volumegroups
7416 fi
7417 }
7418 complete -F _vgdisplay vgdisplay
7419
7420 _vgchange()
7421 {
7422 local cur prev
7423
7424 COMPREPLY=()
7425 cur=`_get_cword`
7426 prev=${COMP_WORDS[COMP_CWORD-1]}
7427
7428 case "$prev" in
7429 -@(a|A|x|-available|-autobackup|-resizeable))
7430 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7431 return 0
7432 ;;
7433 esac
7434
7435 if [[ "$cur" == -* ]]; then
7436 COMPREPLY=( $( compgen -W '-A --autobackup --alloc -P \
7437 --partial -d --debug -h --help --ignorelockingfailure \
7438 -t --test -u --uuid -v --verbose --version -a \
7439 --available -x --resizeable -l --logicalvolume \
7440 --addtag --deltag' -- $cur ) )
7441 else
7442 _volumegroups
7443 fi
7444 }
7445 complete -F _vgchange vgchange
7446
7447 _vgcreate()
7448 {
7449 local cur prev
7450
7451 COMPREPLY=()
7452 cur=`_get_cword`
7453 prev=${COMP_WORDS[COMP_CWORD-1]}
7454
7455 case "$prev" in
7456 -@(A|-autobackup))
7457 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7458 return 0
7459 ;;
7460 -@(M|-metadatatype))
7461 COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
7462 return 0
7463 ;;
7464 -@(s|-physicalextentsize))
7465 _sizes
7466 return 0
7467 ;;
7468 esac
7469
7470 if [[ "$cur" == -* ]]; then
7471 COMPREPLY=( $( compgen -W '-A --autobackup --addtag \
7472 --alloc -d --debug -h --help -l --maxlogicalvolumes \
7473 -M --metadatatype -p --maxphysicalvolumes -s \
7474 --physicalextentsize -t --test -v --verbose \
7475 --version' -- $cur ) )
7476 else
7477 _args
7478 if [ $args -eq 0 ]; then
7479 _volumegroups
7480 else
7481 _physicalvolumes
7482 fi
7483 fi
7484 }
7485 complete -F _vgcreate vgcreate
7486
7487 _vgremove()
7488 {
7489 local cur
7490
7491 COMPREPLY=()
7492 cur=`_get_cword`
7493
7494 if [[ "$cur" == -* ]]; then
7495 COMPREPLY=( $( compgen -W '-d --debug -h --help -t --test \
7496 -v --verbose --version' -- $cur ) )
7497 else
7498 _volumegroups
7499 fi
7500 }
7501 complete -F _vgremove vgremove
7502
7503 _vgrename()
7504 {
7505 local cur prev
7506
7507 COMPREPLY=()
7508 cur=`_get_cword`
7509 prev=${COMP_WORDS[COMP_CWORD-1]}
7510
7511 case "$prev" in
7512 -@(A|-autobackup))
7513 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7514 return 0
7515 ;;
7516 esac
7517
7518 if [[ "$cur" == -* ]]; then
7519 COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
7520 -? --help -t --test -v --verbose --version' -- $cur ) )
7521 else
7522 _volumegroups
7523 fi
7524 }
7525 complete -F _vgrename vgrename
7526
7527 _vgreduce()
7528 {
7529 local cur prev
7530
7531 COMPREPLY=()
7532 cur=`_get_cword`
7533 prev=${COMP_WORDS[COMP_CWORD-1]}
7534
7535 case "$prev" in
7536 -@(A|-autobackup))
7537 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7538 return 0
7539 ;;
7540 esac
7541
7542 if [[ "$cur" == -* ]]; then
7543 COMPREPLY=( $( compgen -W '-a --all -A --autobackup -d \
7544 --debug -h --help --removemissing -t --test -v \
7545 --verbose --version' -- $cur ) )
7546
7547 else
7548 _args
7549 if [ $args -eq 0 ]; then
7550 _volumegroups
7551 else
7552 _physicalvolumes
7553 fi
7554 fi
7555 }
7556 complete -F _vgreduce vgreduce
7557
7558 _vgextend()
7559 {
7560 local cur prev
7561
7562 COMPREPLY=()
7563 cur=`_get_cword`
7564 prev=${COMP_WORDS[COMP_CWORD-1]}
7565
7566 case "$prev" in
7567 -@(A|-autobackup))
7568 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7569 return 0
7570 ;;
7571 -@(L|-size))
7572 _sizes
7573 return 0
7574 ;;
7575 esac
7576
7577 if [[ "$cur" == -* ]]; then
7578 COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
7579 -? --help -t --test -v --verbose --version' -- $cur ) )
7580 else
7581 _args
7582 if [ $args -eq 0 ]; then
7583 _volumegroups
7584 else
7585 _physicalvolumes
7586 fi
7587 fi
7588 }
7589 complete -F _vgextend vgextend
7590
7591 _vgport()
7592 {
7593 local cur prev
7594
7595 COMPREPLY=()
7596 cur=`_get_cword`
7597
7598 if [[ "$cur" == -* ]]; then
7599 COMPREPLY=( $( compgen -W '-a --all -d --debug -h \
7600 -? --help -v --verbose --version' -- $cur ) )
7601 else
7602 _volumegroups
7603 fi
7604 }
7605 complete -F _vgport vgimport vgexport
7606
7607 _vgck()
7608 {
7609 local cur prev
7610
7611 COMPREPLY=()
7612 cur=`_get_cword`
7613
7614 if [[ "$cur" == -* ]]; then
7615 COMPREPLY=( $( compgen -W '-d --debug -h \
7616 -? --help -v --verbose --version' -- $cur ) )
7617 else
7618 _volumegroups
7619 fi
7620 }
7621 complete -F _vgck vgck
7622
7623 _vgconvert()
7624 {
7625 local cur prev
7626
7627 COMPREPLY=()
7628 cur=`_get_cword`
7629 prev=${COMP_WORDS[COMP_CWORD-1]}
7630
7631 case "$prev" in
7632 -@(M|-metadatatype))
7633 COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
7634 return 0
7635 ;;
7636 --metadatacopies)
7637 COMPREPLY=( $( compgen -W '0 1 2' -- $cur ) )
7638 return 0
7639 ;;
7640 --metadatasize)
7641 _sizes
7642 return 0
7643 ;;
7644 esac
7645
7646 if [[ "$cur" == -* ]]; then
7647 COMPREPLY=( $( compgen -W '-d --debug -h --help --labelsector \
7648 -M --metadatatype --metadatacopies --metadatasize \
7649 -t --test -v --verbose --version' -- $cur ) )
7650 else
7651 _volumegroups
7652 fi
7653 }
7654 complete -F _vgconvert vgconvert
7655
7656 _vgcfgbackup()
7657 {
7658 local cur prev
7659
7660 COMPREPLY=()
7661 cur=`_get_cword`
7662 prev=${COMP_WORDS[COMP_CWORD-1]}
7663
7664 case "$prev" in
7665 -@(f|-file))
7666 _filedir
7667 return 0
7668 ;;
7669 esac
7670
7671 if [[ "$cur" == -* ]]; then
7672 COMPREPLY=( $( compgen -W '-d --debug -f --file -h --help \
7673 --ignorelockingfailure -P --partial -v --verbose \
7674 --version' -- $cur ) )
7675 else
7676 _volumegroups
7677 fi
7678 }
7679 complete -F _vgcfgbackup vgcfgbackup
7680
7681 _vgcfgrestore()
7682 {
7683 local cur prev
7684
7685 COMPREPLY=()
7686 cur=`_get_cword`
7687 prev=${COMP_WORDS[COMP_CWORD-1]}
7688
7689 case "$prev" in
7690 -@(f|-file))
7691 _filedir
7692 return 0
7693 ;;
7694 -@(M|-metadatatype))
7695 COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
7696 return 0
7697 ;;
7698 -@(n|-name))
7699 _volumegroups
7700 return 0
7701 ;;
7702 esac
7703
7704 if [[ "$cur" == -* ]]; then
7705 COMPREPLY=( $( compgen -W '-d --debug -f --file -l --list \
7706 -h --help -M --Metadatatype -n --name -t --test \
7707 -v --verbose --version' -- $cur ) )
7708 else
7709 _volumegroups
7710 fi
7711 }
7712 complete -F _vgcfgrestore vgcfgrestore
7713
7714 _vgmerge()
7715 {
7716 local cur prev
7717
7718 COMPREPLY=()
7719 cur=`_get_cword`
7720 prev=${COMP_WORDS[COMP_CWORD-1]}
7721
7722 case "$prev" in
7723 -@(A|-autobackup))
7724 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7725 return 0
7726 ;;
7727 esac
7728
7729 if [[ "$cur" == -* ]]; then
7730 COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \
7731 -h --help -l --list -t --test -v --verbose \
7732 --version' -- $cur ) )
7733 else
7734 _volumegroups
7735 fi
7736 }
7737 complete -F _vgmerge vgmerge
7738
7739 _vgsplit()
7740 {
7741 local cur prev
7742
7743 COMPREPLY=()
7744 cur=`_get_cword`
7745 prev=${COMP_WORDS[COMP_CWORD-1]}
7746
7747 case "$prev" in
7748 -@(A|-autobackup))
7749 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7750 return 0
7751 ;;
7752 -@(M|-metadatatype))
7753 COMPREPLY=( $( compgen -W '1 2' -- $cur ) )
7754 return 0
7755 ;;
7756 esac
7757
7758 if [[ "$cur" == -* ]]; then
7759 COMPREPLY=( $( compgen -W '-A --autobackup -d --debug \
7760 -h --help -l --list -M --metadatatype -t --test \
7761 -v --verbose --version' -- $cur ) )
7762 else
7763 _args
7764 if [ $args -eq 0 -o $args -eq 1 ]; then
7765 _volumegroups
7766 else
7767 _physicalvolumes
7768 fi
7769 fi
7770 }
7771 complete -F _vgsplit vgsplit
7772
7773 _vgmknodes()
7774 {
7775 local cur
7776
7777 COMPREPLY=()
7778 cur=`_get_cword`
7779
7780 if [[ "$cur" == -* ]]; then
7781 COMPREPLY=( $( compgen -W '-d --debug -h --help -v --verbose \
7782 --version' -- $cur ) )
7783 else
7784 _volumegroups
7785 fi
7786 }
7787 complete -F _vgmknodes vgmknodes
7788
7789 _lvscan()
7790 {
7791 local cur
7792
7793 COMPREPLY=()
7794 cur=`_get_cword`
7795
7796 if [[ "$cur" == -* ]]; then
7797 COMPREPLY=( $( compgen -W '-b --blockdevice -d --debug \
7798 -h -? --help --ignorelockingfailure -P \
7799 --partial -v --verbose --version' -- $cur ) )
7800 fi
7801 }
7802 complete -F _lvscan lvscan
7803
7804 _lvs()
7805 {
7806 local cur prev
7807
7808 COMPREPLY=()
7809 cur=`_get_cword`
7810 prev=${COMP_WORDS[COMP_CWORD-1]}
7811
7812 case "$prev" in
7813 -@(o|O|-options|-sort))
7814 COMPREPLY=( $( compgen -W 'lv_uuid lv_name \
7815 lv_attr lv_minor lv_size seg_count \
7816 origin snap_percent segtype stripes \
7817 stripesize chunksize seg_start \
7818 seg_size' -- $cur ) )
7819 return 0
7820 ;;
7821 --units)
7822 _units
7823 return 0
7824 ;;
7825 esac
7826
7827 if [[ "$cur" == -* ]]; then
7828 COMPREPLY=( $( compgen -W '--aligned -d --debug \
7829 -h --help --ignorelockingfailure --noheadings \
7830 --nosuffix -o --options -O --sort -P --partial \
7831 --segments --separator --unbuffered --units \
7832 -v --verbose --version' -- $cur ) )
7833 else
7834 _logicalvolumes
7835 fi
7836 }
7837 complete -F _lvs lvs
7838
7839 _lvdisplay()
7840 {
7841 local cur prev
7842
7843 COMPREPLY=()
7844 cur=`_get_cword`
7845 prev=${COMP_WORDS[COMP_CWORD-1]}
7846
7847 case "$prev" in
7848 --units)
7849 _units
7850 return 0
7851 ;;
7852 esac
7853
7854 if [[ "$cur" == -* ]]; then
7855 COMPREPLY=( $( compgen -W '-c --colon -C --columns --units \
7856 -P --partial -m --maps -v --verbose -d --debug -h \
7857 --help --version' -- $cur ) )
7858 else
7859 _logicalvolumes
7860 fi
7861 }
7862 complete -F _lvdisplay lvdisplay
7863
7864 _lvchange()
7865 {
7866 local cur prev
7867
7868 COMPREPLY=()
7869 cur=`_get_cword`
7870 prev=${COMP_WORDS[COMP_CWORD-1]}
7871
7872 case "$prev" in
7873 -@(a|A|C|M|-available|-autobackup|-continguous|-persistent))
7874 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7875 return 0
7876 ;;
7877 -@(p|-permission))
7878 COMPREPLY=( $( compgen -W 'r rw' -- $cur ) )
7879 return 0
7880 ;;
7881 esac
7882
7883 if [[ "$cur" == -* ]]; then
7884 COMPREPLY=( $( compgen -W '-A --autobackup -a --available \
7885 --addtag --alloc -C --contiguous -d --debug --deltag \
7886 -f --force -h --help --ignorelockingfailure -M \
7887 --persistent --major major --minor minor -P --partial \
7888 -p --permission -r --readahead --refresh -t --test \
7889 -v --verbose --version' -- $cur ) )
7890 else
7891 _logicalvolumes
7892 fi
7893 }
7894 complete -F _lvchange lvchange
7895
7896 _lvcreate()
7897 {
7898 local cur prev
7899
7900 COMPREPLY=()
7901 cur=`_get_cword`
7902 prev=${COMP_WORDS[COMP_CWORD-1]}
7903
7904 case "$prev" in
7905 -@(A|C|M|Z|-autobackup|-continguous|-persistent|-zero))
7906 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7907 return 0
7908 ;;
7909 -@(L|-size))
7910 _sizes
7911 return 0
7912 ;;
7913 -@(p|-permission))
7914 COMPREPLY=( $( compgen -W 'r rw' -- $cur ) )
7915 return 0
7916 ;;
7917 -@(n|-name))
7918 _logicalvolumes
7919 return 0
7920 ;;
7921 esac
7922
7923 if [[ "$cur" == -* ]]; then
7924 COMPREPLY=( $( compgen -W '-A --autobackup --addtag --alloc \
7925 -C --contiguous -d --debug -h -? --help -i --stripes \
7926 -I --stripesize -l --extents -L --size -M --persistent \
7927 --major --minor -n --name -p --permission -r \
7928 --readahead -t --test --type -v --verbose -Z --zero \
7929 --version' -- $cur ) )
7930 else
7931 _args
7932 if [ $args -eq 0 ]; then
7933 _volumegroups
7934 else
7935 _physicalvolumes
7936 fi
7937 fi
7938 }
7939 complete -F _lvcreate lvcreate
7940
7941 _lvremove()
7942 {
7943 local cur prev
7944
7945 COMPREPLY=()
7946 cur=`_get_cword`
7947 prev=${COMP_WORDS[COMP_CWORD-1]}
7948
7949 case "$prev" in
7950 -@(A|-autobackup))
7951 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7952 return 0
7953 ;;
7954 esac
7955
7956 if [[ "$cur" == -* ]]; then
7957 COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -f \
7958 --force -h -? --help -t --test -v --verbose \
7959 --version' -- $cur ) )
7960 else
7961 _logicalvolumes
7962 fi
7963 }
7964 complete -F _lvremove lvremove
7965
7966 _lvrename()
7967 {
7968 local cur prev
7969
7970 COMPREPLY=()
7971 cur=`_get_cword`
7972 prev=${COMP_WORDS[COMP_CWORD-1]}
7973
7974 case "$prev" in
7975 -@(A|-autobackup))
7976 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
7977 return 0
7978 ;;
7979 esac
7980
7981 if [[ "$cur" == -* ]]; then
7982 COMPREPLY=( $( compgen -W '-A --autobackup -d --debug -h \
7983 -? --help -t --test -v --verbose --version' -- $cur ) )
7984 else
7985 _logicalvolumes
7986 fi
7987 }
7988 complete -F _lvrename lvrename
7989
7990 _lvreduce()
7991 {
7992 local cur prev
7993
7994 COMPREPLY=()
7995 cur=`_get_cword`
7996 prev=${COMP_WORDS[COMP_CWORD-1]}
7997
7998 case "$prev" in
7999 -@(A|-autobackup))
8000 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
8001 return 0
8002 ;;
8003 -@(L|-size))
8004 _sizes
8005 return 0
8006 ;;
8007 esac
8008
8009 if [[ "$cur" == -* ]]; then
8010 COMPREPLY=( $( compgen -W '-A --autobackup -d \
8011 --debug -f --force -h --help -l --extents \
8012 -L --size -n --nofsck -r --resizefs -t --test \
8013 -v --verbose --version' -- $cur ) )
8014 else
8015 _logicalvolumes
8016 fi
8017 }
8018 complete -F _lvreduce lvreduce
8019
8020 _lvresize()
8021 {
8022 local cur prev
8023
8024 COMPREPLY=()
8025 cur=`_get_cword`
8026 prev=${COMP_WORDS[COMP_CWORD-1]}
8027
8028 case "$prev" in
8029 -@(A|-autobackup))
8030 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
8031 return 0
8032 ;;
8033 -@(L|-size))
8034 _sizes
8035 return 0
8036 ;;
8037 esac
8038
8039 if [[ "$cur" == -* ]]; then
8040 COMPREPLY=( $( compgen -W '-A --autobackup --alloc -d \
8041 --debug -h --help -i --stripes -I --stripesize \
8042 -l --extents -L --size -n --nofsck -r --resizefs \
8043 -t --test --type -v --verbose --version' -- $cur ) )
8044 else
8045 _args
8046 if [ $args -eq 0 ]; then
8047 _logicalvolumes
8048 else
8049 _physicalvolumes
8050 fi
8051 fi
8052 }
8053 complete -F _lvresize lvresize
8054
8055 _lvextend()
8056 {
8057 local cur prev
8058
8059 COMPREPLY=()
8060 cur=`_get_cword`
8061 prev=${COMP_WORDS[COMP_CWORD-1]}
8062
8063 case "$prev" in
8064 -@(A|-autobackup))
8065 COMPREPLY=( $( compgen -W 'y n' -- $cur ) )
8066 return 0
8067 ;;
8068 -@(L|-size))
8069 _sizes
8070 return 0
8071 ;;
8072 esac
8073
8074 if [[ "$cur" == -* ]]; then
8075 COMPREPLY=( $( compgen -W '-A --autobackup --alloc -d \
8076 --debug -h --help -i --stripes -I --stripesize \
8077 -l --extents -L --size -n --nofsck -r --resizefs \
8078 -t --test --type -v --verbose --version' -- $cur ) )
8079 else
8080 _args
8081 if [ $args -eq 0 ]; then
8082 _logicalvolumes
8083 else
8084 _physicalvolumes
8085 fi
8086 fi
8087 }
8088 complete -F _lvextend lvextend
8089
8090 _lvm()
8091 {
8092 local prev
8093
8094 COMPREPLY=()
8095 cur=`_get_cword`
8096
8097 if [ $COMP_CWORD -eq 1 ]; then
8098 COMPREPLY=( $( compgen -W 'dumpconfig help lvchange \
8099 lvcreate lvdisplay lvextend lvmchange \
8100 lvmdiskscan lvmsadc lvmsar lvreduce \
8101 lvremove lvrename lvresize lvs lvscan \
8102 pvchange pvcreate pvdata pvdisplay pvmove \
8103 pvremove pvresize pvs pvscan vgcfgbackup \
8104 vgcfgrestore vgchange vgck vgconvert \
8105 vgcreate vgdisplay vgexport vgextend \
8106 vgimport vgmerge vgmknodes vgreduce \
8107 vgremove vgrename vgs vgscan vgsplit \
8108 version' -- $cur ) )
8109 else
8110 case ${COMP_WORDS[1]} in
8111 pvchange)
8112 _pvchange
8113 ;;
8114 pvcreate)
8115 _pvcreate
8116 ;;
8117 pvdisplay)
8118 _pvdisplay
8119 ;;
8120 pvmove)
8121 _pvmove
8122 ;;
8123 pvremove)
8124 _pvremove
8125 ;;
8126 pvresize)
8127 _pvresize
8128 ;;
8129 pvs)
8130 _pvs
8131 ;;
8132 pvscan)
8133 _pvscan
8134 ;;
8135 vgcfgbackup)
8136 _vgcfgbackup
8137 ;;
8138 vgcfgrestore)
8139 _vgcfgrestore
8140 ;;
8141 vgchange)
8142 _vgchange
8143 ;;
8144 vgck)
8145 _vgck
8146 ;;
8147 vgconvert)
8148 _vgconvert
8149 ;;
8150 vgcreate)
8151 _vgcreate
8152 ;;
8153 vgdisplay)
8154 _vgdisplay
8155 ;;
8156 vgexport)
8157 _vgexport
8158 ;;
8159 vgextend)
8160 _vgextend
8161 ;;
8162 vgimport)
8163 _vgimport
8164 ;;
8165 vgmerge)
8166 _vgmerge
8167 ;;
8168 vgmknodes)
8169 _vgmknodes
8170 ;;
8171 vgreduce)
8172 _vgreduce
8173 ;;
8174 vgremove)
8175 _vgremove
8176 ;;
8177 vgrename)
8178 _vgrename
8179 ;;
8180 vgs)
8181 _vgs
8182 ;;
8183 vgscan)
8184 _vgscan
8185 ;;
8186 vgsplit)
8187 _vgsplit
8188 ;;
8189 lvchange)
8190 _lvchange
8191 ;;
8192 lvcreate)
8193 _lvcreate
8194 ;;
8195 lvdisplay)
8196 _lvdisplay
8197 ;;
8198 lvextend)
8199 _lvextend
8200 ;;
8201 lvreduce)
8202 _lvreduce
8203 ;;
8204 lvremove)
8205 _lvremove
8206 ;;
8207 lvrename)
8208 _lvrename
8209 ;;
8210 lvresize)
8211 _lvresize
8212 ;;
8213 lvs)
8214 _lvs
8215 ;;
8216 lvscan)
8217 _lvscan
8218 ;;
8219 esac
8220 fi
8221 }
8222 complete -F _lvm lvm
8223 }
8224
8225 # mkinitrd(8) completion
8226 #
8227 have mkinitrd &&
8228 _mkinitrd()
8229 {
8230 local cur args
8231
8232 COMPREPLY=()
8233 cur=`_get_cword`
8234 prev=${COMP_WORDS[COMP_CWORD-1]}
8235
8236 # --name value style option
8237 case "$prev" in
8238 --preload)
8239 _modules
8240 return 0
8241 ;;
8242 esac
8243
8244 # --name=value style option
8245 if [[ "$cur" == *=* ]]; then
8246 prev=${cur/=*/}
8247 cur=${cur/*=/}
8248 case "$prev" in
8249 --@(with|builtin))
8250 _modules
8251 return 0
8252 ;;
8253 --@(fstab|dsdt))
8254 _filedir
8255 return 0
8256 ;;
8257 --tmpdir)
8258 _filedir -d
8259 return 0
8260 ;;
8261 esac
8262 fi
8263
8264
8265 if [[ "$cur" == -* ]]; then
8266 COMPREPLY=( $( compgen -W '--version -v -f --preload \
8267 --with= --omit-scsi-modules --omit-raid-modules \
8268 --images-version --fstab= --nocompress --builtin= \
8269 --nopivot --noudev --allow-missing --tmpdir= \
8270 --initrdfs= --dsdt= --lvm-version= --froce-usb' \
8271 -- $cur ) )
8272 else
8273 _count_args
8274
8275 case $args in
8276 1)
8277 _filedir
8278 ;;
8279 2)
8280 COMPREPLY=( $( command ls /lib/modules | grep "^$cur" ) )
8281 ;;
8282 esac
8283 fi
8284
8285 } &&
8286 complete -F _mkinitrd mkinitrd
8287
8288 # pkgconfig(1) completion
8289 #
8290 have pkg-config &&
8291 _pkg_config()
8292 {
8293 local cur
8294
8295 COMPREPLY=()
8296 cur=`_get_cword`
8297
8298 if [[ "$cur" == -* ]]; then
8299 # return list of available options
8300 COMPREPLY=( $( compgen -W '-version --modversion \
8301 --atleast-pkgconfig-version= --libs --libs-only-l \
8302 --libs-only-other --libs-only-L --cflags \
8303 --cflags-only-I --cflags-only-other --variable= \
8304 --define-variable= --exists --uninstalled \
8305 --atleast-version= --exact-version= --max-version= \
8306 --list-all --debug --print-errors --silence-errors \
8307 --errors-to-stdout -? --help --usage' -- $cur))
8308 else
8309 COMPREPLY=( $( pkg-config --list-all 2>/dev/null | \
8310 awk '{print $1}' | grep "^$cur" ) )
8311 fi
8312 } &&
8313 complete -F _pkg_config pkg-config
8314
8315
8316 # cpio(1) completion
8317 #
8318 have cpio && {
8319 _cpio_format()
8320 {
8321 COMPREPLY=( $( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- $cur ) )
8322 }
8323
8324 _cpio()
8325 {
8326 local cur
8327
8328 COMPREPLY=()
8329 cur=`_get_cword`
8330 prev=${COMP_WORDS[COMP_CWORD-1]}
8331
8332 # --name value style option
8333 case $prev in
8334 -H)
8335 _cpio_format
8336 return 0
8337 ;;
8338 -@(E|F|I))
8339 _filedir
8340 return 0
8341 ;;
8342 -R)
8343 _usergroup
8344 return 0
8345 ;;
8346 esac
8347
8348 # --name=value style option
8349 if [[ "$cur" == *=* ]]; then
8350 prev=${cur/=*/}
8351 cur=${cur/*=/}
8352 case $prev in
8353 --format)
8354 _cpio_format
8355 return 0
8356 ;;
8357 --@(file|pattern-file))
8358 _filedir
8359 return 0
8360 ;;
8361 --owner)
8362 _usergroup
8363 return 0
8364 ;;
8365 --rsh-command)
8366 COMPREPLY=( $( compgen -c -- $cur ) )
8367 return 0
8368 ;;
8369 esac
8370 fi
8371
8372 if [ $COMP_CWORD -eq 1 ]; then
8373 COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through' -- $cur) )
8374 else
8375 case ${COMP_WORDS[1]} in
8376 -@(o|-create))
8377 if [[ "$cur" == -* ]]; then
8378 COMPREPLY=( $( compgen -W '-0 -a -c -v -A -B\
8379 -L -V -C -H -M -O -F --file= --format=\
8380 --message= --null --reset-access-time\
8381 --verbose --dot --append --block-size=\
8382 --dereference --io-size= --quiet\
8383 --force-local --rsh-command= --help\
8384 --version' -- $cur ) )
8385 fi
8386 ;;
8387 -@(i|-extract))
8388 if [[ "$cur" == -* ]]; then
8389 COMPREPLY=( $( compgen -W '-b -c -d -f -m -n -r\
8390 -t -s -u -v -B -S -V -C -E -H -M -R -I\
8391 -F --file= --make-directories\
8392 --nonmatching\
8393 --preserve-modification-time\
8394 --numeric-uid-gid --rename -t --list\
8395 --swap-bytes --swap --dot\
8396 --unconditional --verbose --block-size=\
8397 --swap-halfwords --io-size=\
8398 --pattern-file= --format= --owner=\
8399 --no-preserve-owner --message=\
8400 --force-local --no-absolute-filenames\
8401 --sparse --only-verify-crc --quiet\
8402 --rsh-command= --help\
8403 --version' -- $cur ) )
8404 fi
8405 ;;
8406 -@(p|-pass-through))
8407 if [[ "$cur" == -* ]]; then
8408 COMPREPLY=( $( compgen -W '-0 -a -d -l -m -u -v\
8409 -L -V -R --null --reset-access-time\
8410 --make-directories --link --quiet\
8411 --preserve-modification-time\
8412 --unconditional --verbose --dot\
8413 --dereference --owner=\
8414 --no-preserve-owner --sparse --help\
8415 --version' -- $cur ) )
8416 else
8417 _filedir -d
8418 fi
8419 ;;
8420 esac
8421 fi
8422 }
8423 complete -F _cpio cpio
8424 }
8425
8426 # id(1) completion
8427 #
8428 have id &&
8429 _id()
8430 {
8431 local cur
8432
8433 COMPREPLY=()
8434 cur=`_get_cword`
8435
8436 if [[ "$cur" == -* ]]; then
8437 COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\
8438 -r --real -u --user --help --version' -- $cur ) )
8439 else
8440 COMPREPLY=( $( compgen -u $cur ) )
8441 fi
8442 } &&
8443 complete -F _id id
8444
8445 # getent(1) completion
8446 #
8447 have getent &&
8448 _getent()
8449 {
8450 local cur prev
8451
8452 COMPREPLY=()
8453 cur=`_get_cword`
8454 prev=${COMP_WORDS[COMP_CWORD-1]}
8455
8456 case $prev in
8457 passwd)
8458 COMPREPLY=( $( compgen -u $cur ) )
8459 return 0
8460 ;;
8461 group)
8462 COMPREPLY=( $( compgen -g $cur ) )
8463 return 0
8464 ;;
8465 services)
8466 COMPREPLY=( $( compgen -s $cur ) )
8467 return 0
8468 ;;
8469 hosts)
8470 COMPREPLY=( $( compgen -A hostname $cur ) )
8471 return 0
8472 ;;
8473 protocols)
8474 COMPREPLY=( $( getent protocols | awk '{print $1}' | grep "^$cur" ) )
8475 return 0
8476 ;;
8477 networks)
8478 COMPREPLY=( $( getent networks | awk '{print $1}' | grep "^$cur" ) )
8479 return 0
8480 ;;
8481 esac
8482
8483
8484 if [ $COMP_CWORD -eq 1 ]; then
8485 COMPREPLY=( $( compgen -W 'passwd group hosts services protocols networks' -- $cur ) )
8486 fi
8487 } &&
8488 complete -F _getent getent
8489
8490 # ntpdate(1) completion
8491 #
8492 have ntpdate &&
8493 _ntpdate()
8494 {
8495 local cur prev
8496
8497 COMPREPLY=()
8498 cur=`_get_cword`
8499 prev=${COMP_WORDS[COMP_CWORD-1]}
8500
8501 case $prev in
8502 -k)
8503 _filedir
8504 return 0
8505 ;;
8506 -U)
8507 COMPREPLY=( $( compgen -u $cur ) )
8508 return 0
8509 ;;
8510 esac
8511
8512 if [[ "$cur" == -* ]]; then
8513 COMPREPLY=( $( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\
8514 -e -k -p -o -r -t' -- $cur ) )
8515 else
8516 _known_hosts
8517 fi
8518 } &&
8519 complete -F _ntpdate ntpdate
8520
8521 # smartctl(8) completion
8522 #
8523 have smartctl && {
8524 _smartctl_quietmode()
8525 {
8526 COMPREPLY=( $( compgen -W 'errorsonly silent' -- $cur ) )
8527 }
8528 _smartctl_device()
8529 {
8530 COMPREPLY=( $( compgen -W 'ata scsi 3ware' -- $cur ) )
8531 }
8532 _smartctl_tolerance()
8533 {
8534 COMPREPLY=( $( compgen -W 'warn exit ignore' -- $cur ) )
8535 }
8536 _smartctl_badsum()
8537 {
8538 COMPREPLY=( $( compgen -W 'normal conservative permissive verypermissive' -- $cur ) )
8539 }
8540 _smartctl_report()
8541 {
8542 COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- $cur ) )
8543 }
8544 _smartctl_feature()
8545 {
8546 COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
8547 }
8548 _smartctl_log()
8549 {
8550 COMPREPLY=( $( compgen -W 'error selftest selective directory' -- $cur ) )
8551 }
8552 _smartctl_vendorattribute()
8553 {
8554 COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \
8555 9,temp 192,emergencyretractcyclect 193,loadunload \
8556 194,10xCelsius 194,unknown 198,offlinescanuncsectorct \
8557 200,writeerrorcount 201,detectedtacount 220,temp' -- $cur ) )
8558 }
8559 _smartctl_firmwarebug()
8560 {
8561 COMPREPLY=( $( compgen -W 'none samsung samsung2' -- $cur ) )
8562 }
8563 _smartctl_presets()
8564 {
8565 COMPREPLY=( $( compgen -W 'use ignore show showall' -- $cur ) )
8566 }
8567 _smartctl_test()
8568 {
8569 COMPREPLY=( $( compgen -W 'offline short long conveyance select afterselect,on afterselect,off pending' -- $cur ) )
8570 }
8571
8572 _smartctl()
8573 {
8574 local cur prev
8575
8576 COMPREPLY=()
8577 cur=`_get_cword`
8578 prev=${COMP_WORDS[COMP_CWORD-1]}
8579
8580 # --name value style option
8581 case "$prev" in
8582 -q)
8583 _smartctl_quietmode
8584 ;;
8585 -d)
8586 _smartctl_device
8587 return 0
8588 ;;
8589 -t)
8590 _smartctl_tolerance
8591 return 0
8592 ;;
8593 -b)
8594 _smartctl_badsum
8595 return 0
8596 ;;
8597 -r)
8598 _smartctl_report
8599 return 0
8600 ;;
8601 -s)
8602 _smartctl_feature
8603 return 0
8604 ;;
8605 -o)
8606 _smartctl_feature
8607 return 0
8608 ;;
8609 -S)
8610 _smartctl_feature
8611 return 0
8612 ;;
8613 -l)
8614 _smartctl_log
8615 return 0
8616 ;;
8617 -v)
8618 _smartctl_vendorattribute
8619 return 0
8620 ;;
8621 -F)
8622 _smartctl_firmwarebug
8623 return 0
8624 ;;
8625 -P)
8626 _smartctl_presets
8627 return 0
8628 ;;
8629 -t)
8630 _smartctl_test
8631 return 0
8632 ;;
8633 esac
8634
8635 # --name=value style option
8636 if [[ "$cur" == *=* ]]; then
8637 prev=${cur/=*/}
8638 cur=${cur/*=/}
8639 case "$prev" in
8640 --quietmode)
8641 _smartctl_quietmode
8642 return 0
8643 ;;
8644 --device)
8645 _smartctl_device
8646 return 0
8647 ;;
8648 --tolerance)
8649 _smartctl_tolerance
8650 return 0
8651 ;;
8652 --badsum)
8653 _smartctl_badsum
8654 return 0
8655 ;;
8656 --report)
8657 _smartctl_report
8658 return 0
8659 ;;
8660 --smart)
8661 _smartctl_feature
8662 return 0
8663 ;;
8664 --offlineauto)
8665 _smartctl_feature
8666 return 0
8667 ;;
8668 --saveauto)
8669 _smartctl_feature
8670 return 0
8671 ;;
8672 --log)
8673 _smartctl_log
8674 return 0
8675 ;;
8676 --vendorattribute)
8677 _smartctl_vendorattribute
8678 return 0
8679 ;;
8680 --firmwarebug)
8681 _smartctl_firmwarebug
8682 return 0
8683 ;;
8684 --presets)
8685 _smartctl_presets
8686 return 0
8687 ;;
8688 --test)
8689 _smartctl_test
8690 return 0
8691 ;;
8692 esac
8693 fi
8694
8695
8696 if [[ "$cur" == -* ]]; then
8697 COMPREPLY=( $( compgen -W '-h --help --usage -V --version \
8698 --copyright --license-i --info -a --all -q \
8699 --quietmode= -d --device= -T --tolerance= -b --badsum= \
8700 -r --report= -s --smart= -o --offlineauto= -S \
8701 --saveauto= -H --health -c --capabilities -A \
8702 --attributes -l --log= -v --vendorattribute= -F \
8703 --firmwarebug= -P --presets= -t --test= -C \
8704 --captive -X --abort' -- $cur ) )
8705 else
8706 cur=${cur:=/dev/}
8707 _filedir
8708 fi
8709 }
8710 complete -F _smartctl smartctl
8711 }
8712
8713 # vncviewer(1) completion
8714 #
8715 have vncviewer &&
8716 _vncviewer()
8717 {
8718 local cur prev
8719 local -a config
8720
8721 COMPREPLY=()
8722 cur=`_get_cword`
8723 prev=${COMP_WORDS[COMP_CWORD-1]}
8724
8725 case "$prev" in
8726 -via)
8727 _known_hosts -a
8728 ;;
8729 *)
8730 # ssh into the the server, find and ping the broadcast address, then
8731 # sort and show the results.
8732 COMPREPLY=( $( ssh -o 'Batchmode yes' $prev \
8733 "ping -bnc 4 255.255.255.255" 2>/dev/null | \
8734 awk -F ' ' '{print $4}' | \
8735 sort -n | uniq | egrep '[0-9]+\.[0-9]+\.' 2>/dev/null ) )
8736 esac
8737
8738 return 0
8739 } &&
8740 complete -F _vncviewer vncviewer
8741
8742 # sysctl(8) completion
8743 #
8744 have sysctl &&
8745 _sysctl()
8746 {
8747 local cur
8748
8749 COMPREPLY=()
8750 cur=`_get_cword`
8751
8752 COMPREPLY=( $( compgen -W "$(sysctl -N -a 2>/dev/null)" -- $cur ) )
8753
8754 return 0
8755 } &&
8756 complete -F _sysctl sysctl
8757
8758 # update-rc.d(8) completion
8759 #
8760 # Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
8761 #
8762 have update-rc.d &&
8763 _update_rc_d()
8764 {
8765 local cur prev sysvdir services options valid_options
8766
8767 cur=`_get_cword`
8768 prev=${COMP_WORDS[COMP_CWORD-1]}
8769
8770 [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
8771 || sysvdir=/etc/init.d
8772
8773 services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) )
8774 services=( ${services[@]#$sysvdir/} )
8775 options=( -f -n )
8776
8777 if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
8778 valid_options=( $( \
8779 echo "${COMP_WORDS[@]} ${options[@]}" \
8780 | tr " " "\n" \
8781 | sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" \
8782 | sort | uniq -u \
8783 ) )
8784 COMPREPLY=( $( compgen -W '${options[@]} ${services[@]}' \
8785 -X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- $cur ) )
8786 elif [[ "$prev" == ?($( echo ${services[@]} | tr " " "|" )) ]]; then
8787 COMPREPLY=( $( compgen -W 'remove defaults start stop' -- $cur ) )
8788 elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
8789 COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
8790 elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then
8791 COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
8792 elif [[ "$prev" == defaults && -z "$cur" ]]; then
8793 COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 s k )
8794 elif [[ "$prev" == ?(start|stop) ]]; then
8795 if [[ "$cur" == [0-9] || -z "$cur" ]]; then
8796 COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
8797 elif [[ "$cur" == [0-9][0-9] ]]; then
8798 COMPREPLY=( $cur )
8799 else
8800 COMPREPLY=()
8801 fi
8802 elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then
8803 if [[ -z "$cur" ]]; then
8804 if [[ $prev == [0-9][0-9] ]]; then
8805 COMPREPLY=( 0 1 2 3 4 5 6 S )
8806 else
8807 COMPREPLY=( 0 1 2 3 4 5 6 S . )
8808 fi
8809 elif [[ "$cur" == [0-6S.] ]]; then
8810 COMPREPLY=( $cur )
8811 else
8812 COMPREPLY=()
8813 fi
8814 elif [[ "$prev" == "." ]]; then
8815 COMPREPLY=( $(compgen -W "start stop" -- $cur) )
8816 else
8817 COMPREPLY=()
8818 fi
8819
8820 return 0
8821 } &&
8822 complete -F _update_rc_d update-rc.d
8823
8824 # invoke-rc.d(8) completion
8825 #
8826 # Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
8827 #
8828 have invoke-rc.d &&
8829 _invoke_rc_d()
8830 {
8831 local cur prev sysvdir services options valid_options
8832
8833 cur=`_get_cword`
8834 prev=${COMP_WORDS[COMP_CWORD-1]}
8835
8836 [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \
8837 || sysvdir=/etc/init.d
8838
8839 services=( $(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)) )
8840 services=( ${services[@]#$sysvdir/} )
8841 options=( --help --quiet --force --try-anyway --disclose-deny --query --no-fallback )
8842
8843 if [[ ($COMP_CWORD -eq 1) || ("$prev" == --* ) ]]; then
8844 valid_options=( $( \
8845 echo ${COMP_WORDS[@]} ${options[@]} \
8846 | tr " " "\n" \
8847 | sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" \
8848 | sort | uniq -u \
8849 ) )
8850 COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- \
8851 $cur ) )
8852 elif [ -x $sysvdir/$prev ]; then
8853 COMPREPLY=( $( compgen -W '`sed -ne "y/|/ /; \
8854 s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
8855 $sysvdir/$prev`' -- \
8856 $cur ) )
8857 else
8858 COMPREPLY=()
8859 fi
8860
8861 return 0
8862 } &&
8863 complete -F _invoke_rc_d invoke-rc.d
8864
8865 # minicom(1) completion
8866 #
8867 have minicom &&
8868 _minicom()
8869 {
8870 local cur prev
8871
8872 COMPREPLY=()
8873 cur=`_get_cword`
8874 prev=${COMP_WORDS[COMP_CWORD-1]}
8875
8876 case $prev in
8877 -@(a|c))
8878 COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
8879 return 0
8880 ;;
8881 -@(S|C))
8882 _filedir
8883 return 0
8884 ;;
8885 -P)
8886 COMPREPLY=( $( command ls /dev/tty* ) )
8887 COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' -- $cur ) )
8888 return 0
8889 ;;
8890 esac
8891
8892
8893 if [[ "$cur" == -* ]]; then
8894 COMPREPLY=( $( compgen -W '-s -o -m -M -z -l -L -w -a -t \
8895 -c -S -d -p -C -T -8' -- $cur ) )
8896 else
8897 COMPREPLY=( $( command ls /etc/minicom/minirc.* 2>/dev/null | sed -e 's|/etc/minicom/minirc.||' | grep "^$cur" ) )
8898 fi
8899 } &&
8900 complete -F _minicom minicom
8901
8902 # svn completion
8903 #
8904 have svn &&
8905 {
8906 _svn()
8907 {
8908 local cur prev commands options command
8909
8910 COMPREPLY=()
8911 cur=`_get_cword`
8912
8913 commands='add blame praise annotate ann cat checkout co cleanup commit \
8914 ci copy cp delete del remove rm diff di export help ? h import \
8915 info list ls lock log merge mkdir move mv rename ren \
8916 propdel pdel pd propedit pedit pe propget pget pg \
8917 proplist plist pl propset pset ps resolved revert \
8918 status stat st switch sw unlock update up'
8919
8920 if [[ $COMP_CWORD -eq 1 ]] ; then
8921 if [[ "$cur" == -* ]]; then
8922 COMPREPLY=( $( compgen -W '--version' -- $cur ) )
8923 else
8924 COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
8925 fi
8926 else
8927
8928 prev=${COMP_WORDS[COMP_CWORD-1]}
8929 case $prev in
8930 --config-dir)
8931 _filedir -d
8932 return 0;
8933 ;;
8934 -@(F|-file|-targets))
8935 _filedir
8936 return 0;
8937 ;;
8938 --encoding)
8939 COMPREPLY=( $( compgen -W \
8940 '$( iconv --list | sed -e "s@//@@;" )' \
8941 -- "$cur" ) )
8942 return 0;
8943 ;;
8944 --@(editor|diff|diff3)-cmd)
8945 COMP_WORDS=(COMP_WORDS[0] $cur)
8946 COMP_CWORD=1
8947 _command
8948 return 0;
8949 ;;
8950 esac
8951
8952 command=${COMP_WORDS[1]}
8953
8954 if [[ "$cur" == -* ]]; then
8955 # possible options for the command
8956 case $command in
8957 add)
8958 options='--auto-props --no-auto-props \
8959 --force --targets --no-ignore \
8960 --non-recursive -N -q --quiet'
8961 ;;
8962 @(blame|annotate|ann|praise))
8963 options='-r --revisions --username \
8964 --password --no-auth-cache \
8965 --non-interactive -v \
8966 --verbose --incremental --xml'
8967 ;;
8968 cat)
8969 options='-r --revision --username \
8970 --password --no-auth-cache \
8971 --non-interactive'
8972 ;;
8973 @(checkout|co))
8974 options='-r --revision -q --quiet -N \
8975 --non-recursive --username \
8976 --password --no-auth-cache \
8977 --non-interactive \
8978 --ignore-externals'
8979 ;;
8980 cleanup)
8981 options='--diff3-cmd'
8982 ;;
8983 @(commit|ci))
8984 options='-m --message -F --file \
8985 --encoding --force-log -q \
8986 --quiet --non-recursive -N \
8987 --targets --editor-cmd \
8988 --username --password \
8989 --no-auth-cache \
8990 --non-interactive --no-unlock'
8991 ;;
8992 @(copy|cp))
8993 options='-m --message -F --file \
8994 --encoding --force-log -r \
8995 --revision -q --quiet \
8996 --editor-cmd -username \
8997 --password --no-auth-cache \
8998 --non-interactive'
8999 ;;
9000 @(delete|del|remove|rm))
9001 options='--force -m --message -F \
9002 --file --encoding --force-log \
9003 -q --quiet --targets \
9004 --editor-cmd -username \
9005 --password --no-auth-cache \
9006 --non-interactive'
9007 ;;
9008 @(diff|di))
9009 options='-r --revision -x --extensions \
9010 --diff-cmd --no-diff-deleted \
9011 -N --non-recursive --username \
9012 --password --no-auth-cache \
9013 --non-interactive --force \
9014 --old --new --notice-ancestry'
9015 ;;
9016 export)
9017 options='-r --revision -q --quiet \
9018 --username --password \
9019 --no-auth-cache \
9020 --non-interactive -N \
9021 --non-recursive --force \
9022 --native-eol --ignore-externals'
9023 ;;
9024 import)
9025 options='--auto-props --no-auto-props \
9026 -m --message -F --file \
9027 --encoding --force-log -q \
9028 --quiet --non-recursive \
9029 --no-ignore --editor-cmd \
9030 --username --password \
9031 --no-auth-cache \
9032 --non-interactive'
9033 ;;
9034 info)
9035 options='--username --password \
9036 --no-auth-cache \
9037 --non-interactive -r \
9038 --revision --xml --targets \
9039 -R --recursive --incremental'
9040 ;;
9041 @(list|ls))
9042 options='-r --revision -v --verbose -R \
9043 --recursive --username \
9044 --password --no-auth-cache \
9045 --non-interactive \
9046 --incremental --xml'
9047 ;;
9048 lock)
9049 options='-m --message -F --file \
9050 --encoding --force-log \
9051 --targets --force --username \
9052 --password --no-auth-cache \
9053 --non-interactive'
9054 ;;
9055 log)
9056 options='-r --revision -v --verbose \
9057 --targets --username \
9058 --password --no-auth-cache \
9059 --non-interactive \
9060 --stop-on-copy --incremental \
9061 --xml -q --quiet --limit'
9062 ;;
9063 merge)
9064 options='-r --revision -N \
9065 --non-recursive -q --quiet \
9066 --force --dry-run --diff3-cmd \
9067 --username --password \
9068 --no-auth-cache \
9069 --non-interactive \
9070 --ignore-ancestry'
9071 ;;
9072 mkdir)
9073 options='-m --message -F --file \
9074 --encoding --force-log -q \
9075 --quiet --editor-cmd \
9076 --username --password \
9077 --no-auth-cache \
9078 --non-interactive'
9079 ;;
9080 @(move|mv|rename|ren))
9081 options='-m --message -F --file \
9082 --encoding --force-log -r \
9083 --revision -q --quiet \
9084 --force --editor-cmd \
9085 --username --password \
9086 --no-auth-cache \
9087 --non-interactive'
9088 ;;
9089 @(propdel|pdel|pd))
9090 options='-q --quiet -R --recursive -r \
9091 --revision --revprop \
9092 --username --password \
9093 --no-auth-cache \
9094 --non-interactive'
9095 ;;
9096 @(propedit|pedit|pe))
9097 options='-r --revision --revprop \
9098 --encoding --editor-cmd \
9099 --username --password \
9100 --no-auth-cache \
9101 --non-interactive --force'
9102 ;;
9103 @(propget|pget|pg))
9104 options='-R --recursive -r --revision \
9105 --revprop --strict --username \
9106 --password --no-auth-cache \
9107 --non-interactive'
9108 ;;
9109 @(proplist|plist|pl))
9110 options='-v --verbose -R --recursive \
9111 -r --revision --revprop -q \
9112 --quiet --username --password \
9113 --no-auth-cache \
9114 --non-interactive'
9115 ;;
9116 @(propset|pset|ps))
9117 options='-F --file -q --quiet \
9118 --targets -R --recursive \
9119 --revprop --encoding \
9120 --username --password \
9121 --no-auth-cache \
9122 --non-interactive -r \
9123 --revision --force'
9124 ;;
9125 resolved)
9126 options='--targets -R --recursive -q \
9127 --quiet'
9128 ;;
9129 revert)
9130 options='--targets -R --recursive -q \
9131 --quiet'
9132 ;;
9133 @(status|stat|st))
9134 options='-u --show-updates -v \
9135 --verbose -N --non-recursive \
9136 -q --quiet --username \
9137 --password --no-auth-cache \
9138 --non-interactive --no-ignore \
9139 --ignore-externals \
9140 --incremental --xml'
9141 ;;
9142 @(switch|sw))
9143 options='--relocate -r --revision -N \
9144 --non-recursive -q --quiet \
9145 --username --password \
9146 --no-auth-cache \
9147 --non-interactive --diff3-cmd'
9148 ;;
9149 unlock)
9150 options='--targets --force --username \
9151 --password --no-auth-cache \
9152 --non-interactive'
9153 ;;
9154 @(update|up))
9155 options='-r --revision -N \
9156 --non-recursive -q --quiet \
9157 --username --password \
9158 --no-auth-cache \
9159 --non-interactive \
9160 --diff3-cmd --ignore-externals'
9161 ;;
9162 esac
9163 options="$options --help -h --config-dir"
9164
9165 COMPREPLY=( $( compgen -W "$options" -- $cur ) )
9166 else
9167 if [[ "$command" == @(help|h|\?) ]]; then
9168 COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
9169 else
9170 _filedir
9171 fi
9172 fi
9173 fi
9174
9175 return 0
9176 }
9177 complete -F _svn $default svn
9178
9179 _svnadmin()
9180 {
9181 local cur prev commands options mode
9182
9183 COMPREPLY=()
9184 cur=`_get_cword`
9185
9186 commands='create deltify dump help ? hotcopy list-dblogs \
9187 list-unused-dblogs load lslocks lstxns recover rmlocks \
9188 rmtxns setlog verify'
9189
9190 if [[ $COMP_CWORD -eq 1 ]] ; then
9191 if [[ "$cur" == -* ]]; then
9192 COMPREPLY=( $( compgen -W '--version' -- $cur ) )
9193 else
9194 COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
9195 fi
9196 else
9197 prev=${COMP_WORDS[COMP_CWORD-1]}
9198 case $prev in
9199 --config-dir)
9200 _filedir -d
9201 return 0;
9202 ;;
9203 --fs-type)
9204 COMPREPLY=( $( compgen -W 'fsfs bdb' -- $cur ) )
9205 return 0;
9206 ;;
9207 esac
9208
9209 command=${COMP_WORDS[1]}
9210
9211 if [[ "$cur" == -* ]]; then
9212 # possible options for the command
9213 case $command in
9214 create)
9215 options='--bdb-txn-nosync \
9216 --bdb-log-keep --config-dir \
9217 --fs-type'
9218 ;;
9219 deltify)
9220 options='-r --revision -q --quiet'
9221 ;;
9222 dump)
9223 options='-r --revision --incremental \
9224 -q --quiet --deltas'
9225 ;;
9226 hotcopy)
9227 options='--clean-logs'
9228 ;;
9229 load)
9230 options='--ignore-uuid --force-uuid \
9231 --parent-dir -q --quiet \
9232 --use-pre-commit-hook \
9233 --use-post-commit-hook'
9234 ;;
9235 rmtxns)
9236 options='-q --quiet'
9237 ;;
9238 setlog)
9239 options='-r --revision --bypass-hooks'
9240 ;;
9241 esac
9242
9243 options="$options --help -h"
9244 COMPREPLY=( $( compgen -W "$options" -- $cur ) )
9245 else
9246 if [[ "$command" == @(help|h|\?) ]]; then
9247 COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
9248 else
9249 _filedir
9250 fi
9251 fi
9252 fi
9253
9254 return 0
9255 }
9256 complete -F _svnadmin $default svnadmin
9257
9258 _svnlook()
9259 {
9260 local cur prev commands options mode
9261
9262 COMPREPLY=()
9263 cur=`_get_cword`
9264
9265 commands='author cat changed date diff dirs-changed help ? h history \
9266 info lock log propget pget pg proplist plist pl tree uuid \
9267 youngest'
9268
9269 if [[ $COMP_CWORD -eq 1 ]] ; then
9270 if [[ "$cur" == -* ]]; then
9271 COMPREPLY=( $( compgen -W '--version' -- $cur ) )
9272 else
9273 COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
9274 fi
9275 else
9276 command=${COMP_WORDS[1]}
9277
9278 if [[ "$cur" == -* ]]; then
9279 # possible options for the command
9280 case $command in
9281 @(author|cat|date|dirs-changed|info|log))
9282 options='-r --revision -t \
9283 --transaction'
9284 ;;
9285 changed)
9286 options='-r --revision -t \
9287 --transaction --copy-info'
9288 ;;
9289 diff)
9290 options='-r --revision -t \
9291 --transaction \
9292 --no-diff-deleted \
9293 --no-diff-added \
9294 --diff-copy-from'
9295 ;;
9296 history)
9297 options='-r --revision --show-ids'
9298 ;;
9299 prop@(get|list))
9300 options='-r --revision -t \
9301 --transaction --revprop'
9302 ;;
9303 tree)
9304 options='-r --revision -t \
9305 --transaction --show-ids \
9306 --full-paths'
9307 ;;
9308 esac
9309
9310 options="$options --help -h"
9311 COMPREPLY=( $( compgen -W "$options" -- $cur ) )
9312 else
9313 if [[ "$command" == @(help|h|\?) ]]; then
9314 COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
9315 else
9316 _filedir
9317 fi
9318 fi
9319 fi
9320
9321 return 0
9322 }
9323 complete -F _svnlook $default svnlook
9324 }
9325
9326 _filedir_xspec()
9327 {
9328 local IFS cur xspec
9329
9330 IFS=$'\t\n'
9331 COMPREPLY=()
9332 cur=`_get_cword`
9333
9334 _expand || return 0
9335
9336 # get first exclusion compspec that matches this command
9337 xspec=$( sed -ne $'/^complete .*[ \t]'${1##*/}$'\([ \t]\|$\)/{p;q;}' \
9338 $BASH_COMPLETION )
9339 # prune to leave nothing but the -X spec
9340 xspec=${xspec#*-X }
9341 xspec=${xspec%% *}
9342
9343 local toks=( ) tmp
9344
9345 while read -r tmp; do
9346 [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
9347 done < <( compgen -d -- "$(quote_readline "$cur")" )
9348
9349 while read -r tmp; do
9350 [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
9351 done < <( eval compgen -f -X $xspec -- "\$(quote_readline "\$cur")" )
9352
9353 COMPREPLY=( "${toks[@]}" )
9354 }
9355 list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \
9356 $BASH_COMPLETION | \
9357 # read exclusion compspecs
9358 (
9359 while read line
9360 do
9361 # ignore compspecs that are commented out
9362 if [ "${line#\#}" != "$line" ]; then continue; fi
9363 line=${line%# START exclude*}
9364 line=${line%# FINISH exclude*}
9365 line=${line##*\'}
9366 list=( "${list[@]}" $line )
9367 done
9368 echo "${list[@]}"
9369 )
9370 ) )
9371 # remove previous compspecs
9372 if [ ${#list[@]} -gt 0 ]; then
9373 eval complete -r ${list[@]}
9374 # install new compspecs
9375 eval complete -F _filedir_xspec $filenames "${list[@]}"
9376 fi
9377 unset list
9378
9379 # source completion directory definitions
9380 if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \
9381 -x $BASH_COMPLETION_DIR ]; then
9382 for i in $BASH_COMPLETION_DIR/*; do
9383 [[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|.rpm*) ]] &&
9384 [ \( -f $i -o -h $i \) -a -r $i ] && . $i
9385 done
9386 fi
9387 unset i
9388
9389 # source user completion file
9390 [ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \
9391 && . ~/.bash_completion
9392 unset -f have
9393 unset UNAME RELEASE default dirnames filenames have nospace bashdefault \
9394 plusdirs
9395
9396 set $BASH_COMPLETION_ORIGINAL_V_VALUE
9397 unset BASH_COMPLETION_ORIGINAL_V_VALUE
9398
9399 ### Local Variables:
9400 ### mode: shell-script
9401 ### End: