64
56
# Make directory commands see only directories
67
# The following section lists completions that are redefined later
68
# Do NOT break these over multiple lines.
70
# START exclude -- do NOT remove this line
71
# bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510
72
complete -f -X '!*.?(t)bz?(2)' bunzip2 bzcat pbunzip2 pbzcat
73
complete -f -X '!*.@(zip|[ejw]ar|exe|pk3|wsz|zargo|xpi|sxw|o[tx]t|od[fgpst]|epub|apk)' unzip zipinfo
74
complete -f -X '*.Z' compress znew
75
# zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510
76
complete -f -X '!*.@(Z|[gGd]z|t[ag]z)' gunzip zcat unpigz
77
complete -f -X '!*.Z' uncompress
78
# lzcmp, lzdiff intentionally not here, see Debian: #455510
79
complete -f -X '!*.@(tlz|lzma)' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma
80
complete -f -X '!*.@(?(t)xz|tlz|lzma)' unxz xzcat
81
complete -f -X '!*.lrz' lrunzip
82
complete -f -X '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx)' ee
83
complete -f -X '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm)' xv qiv
84
complete -f -X '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview
85
complete -f -X '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi kdvi
86
complete -f -X '!*.dvi' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx
87
complete -f -X '!*.[pf]df' acroread gpdf xpdf
88
complete -f -X '!*.@(?(e)ps|pdf)' kpdf
89
complete -f -X '!*.@(@(?(e)ps|?(E)PS|[pf]df|[PF]DF|dvi|DVI)?(.gz|.GZ|.bz2|.BZ2)|cb[rz]|djv?(u)|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|fdf)' evince
90
complete -f -X '!*.@(okular|@(?(e|x)ps|?(E|X)PS|pdf|PDF|dvi|DVI|cb[rz]|CB[RZ]|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|epub|EPUB|odt|ODT|fb?(2)|FB?(2)|mobi|MOBI|g3|G3|chm|CHM|fdf|FDF)?(.?(gz|GZ|bz2|BZ2)))' okular
91
complete -f -X '!*.@(?(e)ps|pdf)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr
92
complete -f -X '!*.texi*' makeinfo texi2html
93
complete -f -X '!*.@(?(la)tex|texi|dtx|ins|ltx)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
94
complete -f -X '!*.mp3' mpg123 mpg321 madplay
95
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|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.part)' xine aaxine fbxine
96
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|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.part)' kaffeine dragon
97
complete -f -X '!*.@(avi|asf|wmv)' aviplay
98
complete -f -X '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay
99
complete -f -X '!*.@(mpg|mpeg|avi|mov|qt)' xanim
100
complete -f -X '!*.@(og[ag]|m3u|flac|spx)' ogg123
101
complete -f -X '!*.@(mp3|og[ag]|pls|m3u)' gqmpeg freeamp
102
complete -f -X '!*.fig' xfig
103
complete -f -X '!*.@(mid?(i)|cmf)' playmidi
104
complete -f -X '!*.@(mid?(i)|rmi|rcp|[gr]36|g18|mod|xm|it|x3m|s[3t]m|kar)' timidity
105
complete -f -X '!*.@(m[eo]d|s[3t]m|xm|it)' modplugplay modplug123
106
complete -f -X '*.@(o|so|so.!(conf)|a|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)' vi vim gvim rvim view rview rgvim rgview gview emacs xemacs sxemacs kate kwrite
107
complete -f -X '!*.@([eE][xX][eE]?(.[sS][oO])|[cC][oO][mM]|[sS][cC][rR])' wine
108
complete -f -X '!*.@(zip|z|gz|tgz)' bzme
109
# konqueror not here on purpose, it's more than a web/html browser
110
complete -f -X '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon dillo elinks amaya firefox mozilla-firefox iceweasel google-chrome chromium-browser epiphany
111
complete -f -X '!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|odt|ott|odm)' oowriter
112
complete -f -X '!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|odp|otp)' ooimpress
113
complete -f -X '!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|ods|ots)' oocalc
114
complete -f -X '!*.@(sxd|std|sda|sdd|odg|otg)' oodraw
115
complete -f -X '!*.@(sxm|smf|mml|odf)' oomath
116
complete -f -X '!*.odb' oobase
117
complete -f -X '!*.[rs]pm' rpm2cpio
118
complete -f -X '!*.aux' bibtex
119
complete -f -X '!*.po' poedit gtranslator kbabel lokalize
120
complete -f -X '!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])' harbour gharbour hbpp
121
complete -f -X '!*.[Hh][Rr][Bb]' hbrun
122
complete -f -X '!*.ly' lilypond ly2dvi
123
complete -f -X '!*.@(dif?(f)|?(d)patch)?(.@([gx]z|bz2|lzma))' cdiff
124
complete -f -X '!*.lyx' lyx
125
complete -f -X '!@(*.@(ks|jks|jceks|p12|pfx|bks|ubr|gkr|cer|crt|cert|p7b|pkipath|pem|p10|csr|crl)|cacerts)' portecle
126
complete -f -X '!*.@(mp[234c]|og[ag]|@(fl|a)ac|m4[abp]|spx|tta|w?(a)v|wma|aif?(f)|asf|ape)' kid3 kid3-qt
127
# FINISH exclude -- do not remove this line
129
59
# start of section containing compspecs that can be handled within bash
131
61
# user commands see only users
132
complete -u su write chfn groups slay w sux runuser
62
complete -u write chfn groups slay w sux runuser
134
64
# bg completes with stopped jobs
135
65
complete -A stopped -P '"%' -S '"' bg
290
250
# Are characters excluded which were former included?
291
251
if [[ $exclude ]]; then
292
252
# Yes, list of word completion separators has shrunk;
293
254
# Re-assemble words to complete
294
255
for (( i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
295
256
# Is current word not word 0 (the command itself) and is word not
296
# empty and is word made up of just word separator characters to be
298
while [[ $i -gt 0 && ${COMP_WORDS[$i]} &&
299
${COMP_WORDS[$i]//[^$exclude]} == ${COMP_WORDS[$i]}
301
[ $j -ge 2 ] && ((j--))
302
# Append word separator to current word
257
# empty and is word made up of just word separator characters to
258
# be excluded and is current word not preceded by whitespace in
260
while [[ $i -gt 0 && ${COMP_WORDS[$i]} == +([$exclude]) ]]; do
261
# Is word separator not preceded by whitespace in original line
262
# and are we not going to append to word 0 (the command
263
# itself), then append to current word.
264
[[ $line != [$' \t']* ]] && (( j >= 2 )) && ((j--))
265
# Append word separator to current or new word
304
267
eval $2[$j]=\${!ref}\${COMP_WORDS[i]}
305
268
# Indicate new cword
306
[ $i = $COMP_CWORD ] && eval $3=$j
307
# Indicate next word if available, else end *both* while and for loop
269
[[ $i == $COMP_CWORD ]] && eval $3=$j
270
# Remove optional whitespace + word separator from line copy
271
line=${line#*"${COMP_WORDS[$i]}"}
272
# Start new word if word separator in original line is
273
# followed by whitespace.
274
[[ $line == [$' \t']* ]] && ((j++))
275
# Indicate next word if available, else end *both* while and
308
277
(( $i < ${#COMP_WORDS[@]} - 1)) && ((i++)) || break 2
310
279
# Append word to current word
312
281
eval $2[$j]=\${!ref}\${COMP_WORDS[i]}
282
# Remove optional whitespace + word from line copy
283
line=${line#*"${COMP_WORDS[i]}"}
313
284
# Indicate new cword
314
285
[[ $i == $COMP_CWORD ]] && eval $3=$j
323
294
# @param $1 exclude Characters out of $COMP_WORDBREAKS which should NOT be
324
295
# considered word breaks. This is useful for things like scp where
325
296
# we want to return host:path and not only path, so we would pass the
326
# colon (:) as $1 in this case. Bash-3 doesn't do word splitting, so this
327
# ensures we get the same word on both bash-3 and bash-4.
297
# colon (:) as $1 in this case.
328
298
# @param $2 words Name of variable to return words to
329
299
# @param $3 cword Name of variable to return cword to
330
300
# @param $4 cur Name of variable to return current word to complete to
331
# @see ___get_cword_at_cursor_by_ref()
332
__get_cword_at_cursor_by_ref() {
301
# @see __reassemble_comp_words_by_ref()
302
__get_cword_at_cursor_by_ref()
333
304
local cword words=()
334
305
__reassemble_comp_words_by_ref "$1" words cword
337
local cur="$COMP_LINE"
338
local index="$COMP_POINT"
339
for (( i = 0; i <= cword; ++i )); do
341
# Current word fits in $cur?
342
"${#cur}" -ge ${#words[i]} &&
343
# $cur doesn't match cword?
344
"${cur:0:${#words[i]}}" != "${words[i]}"
346
# Strip first character
348
# Decrease cursor position
307
local i cur index=$COMP_POINT lead=${COMP_LINE:0:$COMP_POINT}
308
# Cursor not at position 0 and not leaded by just space(s)?
309
if [[ $index -gt 0 && ( $lead && ${lead//[[:space:]]} ) ]]; then
311
for (( i = 0; i <= cword; ++i )); do
313
# Current word fits in $cur?
314
${#cur} -ge ${#words[i]} &&
315
# $cur doesn't match cword?
316
"${cur:0:${#words[i]}}" != "${words[i]}"
318
# Strip first character
320
# Decrease cursor position
324
# Does found word match cword?
325
if [[ $i -lt $cword ]]; then
326
# No, cword lies further;
327
local old_size=${#cur}
328
cur="${cur#"${words[i]}"}"
329
local new_size=${#cur}
330
index=$(( index - old_size + new_size ))
352
# Does found word matches cword?
353
if [[ "$i" -lt "$cword" ]]; then
354
# No, cword lies further;
355
local old_size="${#cur}"
356
cur="${cur#${words[i]}}"
357
local new_size="${#cur}"
358
index=$(( index - old_size + new_size ))
362
if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then
363
# We messed up. At least return the whole word so things keep working
333
# Clear $cur if just space(s)
334
[[ $cur && ! ${cur//[[:space:]]} ]] && cur=
335
# Zero $index if negative
336
[[ $index -lt 0 ]] && index=0
369
local "$2" "$3" "$4" &&
370
_upvars -a${#words[@]} $2 "${words[@]}" -v $3 "$cword" -v $4 "$cur2"
339
local "$2" "$3" "$4" && _upvars -a${#words[@]} $2 "${words[@]}" \
340
-v $3 "$cword" -v $4 "${cur:0:$index}"
636
562
_tilde "$cur" || return 0
641
567
_quote_readline_by_ref "$cur" quoted
642
toks=( ${toks[@]-} $(
643
compgen -d -- "$quoted" | {
644
while read -r tmp; do
645
# TODO: I have removed a "[ -n $tmp ] &&" before 'printf ..',
646
# and everything works again. If this bug suddenly
647
# appears again (i.e. "cd /b<TAB>" becomes "cd /"),
648
# remember to check for other similar conditionals (here
649
# and _filedir_xspec()). --David
568
x=$( compgen -d -- "$quoted" ) &&
569
while read -r tmp; do
655
573
if [[ "$1" != -d ]]; then
656
574
# Munge xspec to contain uppercase version too
657
[[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
658
xspec=${1:+"!*.@($1|${1^^})"} || \
659
xspec=${1:+"!*.@($1|$(printf %s $1 | tr '[:lower:]' '[:upper:]'))"}
660
toks=( ${toks[@]-} $( compgen -f -X "$xspec" -- $quoted) )
662
[ ${#toks[@]} -ne 0 ] && _compopt_o_filenames
664
# If the filter failed to produce anything, try w/o it (LP: #533985)
665
if [[ -n "$1" ]] && [[ "$1" != -d ]] && [[ ${#toks[@]} -lt 1 ]] ; then
666
toks=( ${toks[@]-} $( compgen -f -X -- $quoted) )
669
COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
575
# http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306
576
xspec=${1:+"!*.@($1|${1^^})"}
577
x=$( compgen -f -X "$xspec" -- $quoted ) &&
578
while read -r tmp; do
583
# If the filter failed to produce anything, try without it if configured to
584
[[ -n ${COMP_FILEDIR_FALLBACK:-} && \
585
-n "$1" && "$1" != -d && ${#toks[@]} -lt 1 ]] && \
586
x=$( compgen -f -- $quoted ) &&
587
while read -r tmp; do
592
if [[ ${#toks[@]} -ne 0 ]]; then
593
# 2>/dev/null for direct invocation, e.g. in the _filedir unit test
594
compopt -o filenames 2>/dev/null
595
COMPREPLY+=( "${toks[@]}" )
673
600
# This function splits $cur=--foo=bar into $prev=--foo, $cur=bar, making it
674
601
# easier to support both "--foo bar" and "--foo=bar" style completions.
602
# `=' should have been removed from COMP_WORDBREAKS when setting $cur for
675
604
# Returns 0 if current option was split, 1 otherwise.
690
# This function tries to parse the help output of the given command.
619
# Complete variables.
620
# @return True (0) if variables were completed,
621
# False (> 0) if not.
624
if [[ $cur =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]; then
625
[[ $cur == *{* ]] && local suffix=} || local suffix=
626
COMPREPLY+=( $( compgen -P ${BASH_REMATCH[1]} -S "$suffix" -v -- \
627
"${BASH_REMATCH[2]}" ) )
633
# Initialize completion and deal with various general things: do file
634
# and variable completion where appropriate, and adjust prev, words,
635
# and cword as if no redirections exist so that completions do not
636
# need to deal with them. Before calling this function, make sure
637
# cur, prev, words, and cword are local, ditto split if you use -s.
640
# -n EXCLUDE Passed to _get_comp_words_by_ref -n with redirection chars
641
# -e XSPEC Passed to _filedir as first arg for stderr redirections
642
# -o XSPEC Passed to _filedir as first arg for other output redirections
643
# -i XSPEC Passed to _filedir as first arg for stdin redirections
644
# -s Split long options with _split_longopt, implies -n =
645
# @return True (0) if completion needs further processing,
646
# False (> 0) no further processing is necessary.
650
local exclude= flag outx errx inx OPTIND=1
652
while getopts "n:e:o:i:s" flag "$@"; do
654
n) exclude+=$OPTARG ;;
658
s) split=false ; exclude+== ;;
662
# For some reason completion functions are not invoked at all by
663
# bash (at least as of 4.1.7) after the command line contains an
664
# ampersand so we don't get a chance to deal with redirections
665
# containing them, but if we did, hopefully the below would also
666
# do the right thing with them...
669
local redir="@(?([0-9])<|?([0-9&])>?(>)|>&)"
670
_get_comp_words_by_ref -n "$exclude<>&" cur prev words cword
672
# Complete variable names.
673
_variables && return 1
675
# Complete on files if current is a redirect possibly followed by a
676
# filename, e.g. ">foo", or previous is a "bare" redirect, e.g. ">".
677
if [[ $cur == $redir* || $prev == $redir ]]; then
680
2'>'*) xspec=$errx ;;
681
*'>'*) xspec=$outx ;;
685
2'>'*) xspec=$errx ;;
686
*'>'*) xspec=$outx ;;
696
# Remove all redirections so completions don't have to deal with them.
698
for (( i=1; i < ${#words[@]}; )); do
699
if [[ ${words[i]} == $redir* ]]; then
700
# If "bare" redirect, remove also the next word (skip=2).
701
[[ ${words[i]} == $redir ]] && skip=2 || skip=1
702
words=( "${words[@]:0:i}" "${words[@]:i+skip}" )
703
[[ $i -le $cword ]] && cword=$(( cword - skip ))
709
[[ $cword -eq 0 ]] && return 1
710
prev=${words[cword-1]}
712
[[ ${split-} ]] && _split_longopt && split=true
717
# Helper function for _parse_help and _parse_usage.
720
local option option2 i IFS=$' \t\n,/|'
722
# Take first found long option, or first one (short) if not found.
727
--?*) option=$i ; break ;;
728
-?*) [[ $option ]] || option=$i ;;
732
[[ $option ]] || return 0
734
IFS=$' \t\n' # affects parsing of the regexps below...
736
# Expand --[no]foo to --foo and --nofoo etc
737
if [[ $option =~ (\[((no|dont)-?)\]). ]]; then
738
option2=${option/"${BASH_REMATCH[1]}"/}
739
option2=${option2%%[<{().[]*}
740
printf '%s\n' "${option2/=*/=}"
741
option=${option/"${BASH_REMATCH[1]}"/"${BASH_REMATCH[2]}"}
744
option=${option%%[<{().[]*}
745
printf '%s\n' "${option/=*/=}"
748
# Parse GNU style help output of the given command.
749
# @param $1 command; if "-", read from stdin and ignore rest of args
692
750
# @param $2 command options (default: --help)
695
$1 ${2:---help} 2>&1 | sed -e '/^[[:space:]]*-/!d' -e 's|[,/]| |g' | \
696
awk '{ print $1; if ($2 ~ /^-/) { print $2 } }' | sed -e 's|[<=].*||'
754
eval local cmd=$( quote "$1" )
758
*) "$( dequote "$cmd" )" ${2:---help} 2>&1 ;;
760
| while read -r line; do
762
[[ $line == *([ $'\t'])-* ]] || continue
763
# transform "-f FOO, --foo=FOO" to "-f , --foo=FOO" etc
765
((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+\]? ]]; do
766
line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"}
768
__parse_options "${line// or /, }"
699
# This function completes on signal names
773
# Parse BSD style usage output (options in brackets) of the given command.
774
# @param $1 command; if "-", read from stdin and ignore rest of args
775
# @param $2 command options (default: --usage)
779
eval local cmd=$( quote "$1" )
780
local line match option i char
783
*) "$( dequote "$cmd" )" ${2:---usage} 2>&1 ;;
785
| while read -r line; do
787
while [[ $line =~ \[[[:space:]]*(-[^]]+)[[:space:]]*\] ]]; do
788
match=${BASH_REMATCH[0]}
789
option=${BASH_REMATCH[1]}
791
-?(\[)+([a-zA-Z0-9?]))
792
# Treat as bundled short options
793
for (( i=1; i < ${#option}; i++ )); do
795
[[ $char != '[' ]] && printf '%s\n' -$char
799
__parse_options "$option"
802
line=${line#*"$match"}
808
# This function completes on signal names (minus the SIG prefix)
705
# standard signal completion is rather braindead, so we need
706
# to hack around to get what we want here, which is to
707
# complete on a dash, followed by the signal name minus
709
COMPREPLY=( $( compgen -A signal SIG${cur#-} ))
710
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
711
COMPREPLY[i]=-${COMPREPLY[i]#SIG}
812
local -a sigs=( $( compgen -P "$1" -A signal "SIG${cur#$1}" ) )
813
COMPREPLY+=( "${sigs[@]/#${1}SIG/${1}}" )
715
816
# This function completes on known mac addresses
1074
# Glob for matching various backup files.
1076
_backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
1078
# Complete on xinetd services
1082
local xinetddir=/etc/xinetd.d
1083
if [[ -d $xinetddir ]]; then
1084
local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
1085
local -a svcs=( $( printf '%s\n' $xinetddir/!($_backup_glob) ) )
1087
COMPREPLY+=( $( compgen -W '${svcs[@]#$xinetddir/}' -- "$cur" ) )
950
1091
# This function completes on services
955
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
957
COMPREPLY=( $( printf '%s\n' \
958
$sysvdir/!(*.rpm@(orig|new|save)|*~|functions) ) )
960
if [ -d $famdir ]; then
961
COMPREPLY=( "${COMPREPLY[@]}" $( printf '%s\n' \
962
$famdir/!(*.rpm@(orig|new|save)|*~) ) )
1098
local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
1099
COMPREPLY=( $( printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions) ) )
1102
COMPREPLY+=( $( systemctl list-units --full --all 2>/dev/null | \
1103
awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }' ) )
1105
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur" ) )
1108
# This completes on a list of all available service scripts for the
1109
# 'service' command and/or the SysV init.d directory, followed by
1110
# that script's available commands
1114
local cur prev words cword
1115
_init_completion || return
1117
# don't complete past 2nd token
1118
[[ $cword -gt 2 ]] && return 0
1120
if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
1122
[[ -e /etc/mandrake-release ]] && _xinetd_services
1126
COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
1127
-ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
1128
${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) )
965
COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- "$cur" ) )
1131
complete -F _service service
1133
for svcdir in ${sysvdirs[@]}; do
1134
for svc in $svcdir/!($_backup_glob); do
1135
[[ -x $svc ]] && complete -F _service $svc
1138
unset svc svcdir sysvdirs
968
1140
# This function completes on modules
1237
1417
p) prefix=$OPTARG ;;
1240
[ $# -lt $OPTIND ] && echo "error: $FUNCNAME: missing mandatory argument CWORD"
1420
[[ $# -lt $OPTIND ]] && echo "error: $FUNCNAME: missing mandatory argument CWORD"
1241
1421
cur=${!OPTIND}; let "OPTIND += 1"
1242
[ $# -ge $OPTIND ] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\
1243
$(while [ $# -ge $OPTIND ]; do printf '%s\n' ${!OPTIND}; shift; done)
1422
[[ $# -ge $OPTIND ]] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\
1423
$(while [[ $# -ge $OPTIND ]]; do printf '%s\n' ${!OPTIND}; shift; done)
1245
1425
[[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
1248
1428
# ssh config files
1249
if [ -n "$configfile" ]; then
1250
[ -r "$configfile" ] &&
1251
config=( "${config[@]}" "$configfile" )
1429
if [[ -n $configfile ]]; then
1430
[[ -r $configfile ]] && config+=( "$configfile" )
1253
for i in /etc/ssh/ssh_config "${HOME}/.ssh/config" \
1254
"${HOME}/.ssh2/config"; do
1255
[ -r $i ] && config=( "${config[@]}" "$i" )
1432
for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do
1433
[[ -r $i ]] && config+=( "$i" )
1259
1437
# Known hosts files from configs
1260
if [ ${#config[@]} -gt 0 ]; then
1261
local OIFS=$IFS IFS=$'\n'
1438
if [[ ${#config[@]} -gt 0 ]]; then
1439
local OIFS=$IFS IFS=$'\n' j
1263
1441
# expand paths (if present) to global and user known hosts files
1264
1442
# TODO(?): try to make known hosts files with more than one consecutive
1265
1443
# spaces in their name work (watch out for ~ expansion
1266
1444
# breakage! Alioth#311595)
1267
1445
tmpkh=( $( awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u ) )
1268
1447
for i in "${tmpkh[@]}"; do
1269
# Remove possible quotes
1271
# Eval/expand possible `~' or `~user'
1272
__expand_tilde_by_ref i
1273
[ -r "$i" ] && kh=( "${kh[@]}" "$i" )
1448
# First deal with quoted entries...
1449
while [[ $i =~ ^([^\"]*)\"([^\"]*)\"(.*)$ ]]; do
1450
i=${BASH_REMATCH[1]}${BASH_REMATCH[3]}
1451
j=${BASH_REMATCH[2]}
1452
__expand_tilde_by_ref j # Eval/expand possible `~' or `~user'
1453
[[ -r $j ]] && kh+=( "$j" )
1455
# ...and then the rest.
1457
__expand_tilde_by_ref j # Eval/expand possible `~' or `~user'
1458
[[ -r $j ]] && kh+=( "$j" )
1278
if [ -z "$configfile" ]; then
1463
if [[ -z $configfile ]]; then
1279
1464
# Global and user known_hosts files
1280
1465
for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \
1281
1466
/etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \
1282
1467
~/.ssh/known_hosts2; do
1283
[ -r $i ] && kh=( "${kh[@]}" $i )
1468
[[ -r $i ]] && kh+=( "$i" )
1285
1470
for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do
1286
[ -d $i ] && khd=( "${khd[@]}" $i/*pub )
1471
[[ -d $i ]] && khd+=( "$i"/*pub )
1340
1527
# append any available aliases from config files
1341
1528
if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then
1342
1529
local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" )
1343
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -P "$prefix$user" \
1530
COMPREPLY+=( $( compgen -P "$prefix$user" \
1344
1531
-S "$suffix" -W "$hosts" -- "$cur" ) )
1347
# Add hosts reported by avahi-browse, if desired and it's available.
1349
1534
# This feature is disabled because it does not scale to
1350
1535
# larger networks. See:
1351
1536
# https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/510591
1538
# Add hosts reported by avahi-browse, if desired and it's available.
1353
1539
#if [[ ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] && \
1354
# type avahi-browse &>/dev/null; then
1540
#type avahi-browse &>/dev/null; then
1355
1541
# The original call to avahi-browse also had "-k", to avoid lookups
1356
1542
# into avahi's services DB. We don't need the name of the service, and
1357
1543
# if it contains ";", it may mistify the result. But on Gentoo (at
1358
1544
# least), -k wasn't available (even if mentioned in the manpage) some
1359
1545
# time ago, so...
1360
# COMPREPLY=( "${COMPREPLY[@]}" $( \
1361
# compgen -P "$prefix$user" -S "$suffix" -W \
1362
# "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \
1363
# awk -F';' '/^=/ { print $7 }' | sort -u )" -- "$cur" ) )
1546
#COMPREPLY+=( $( compgen -P "$prefix$user" -S "$suffix" -W \
1547
# "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \
1548
# awk -F';' '/^=/ { print $7 }' | sort -u )" -- "$cur" ) )
1551
# Add hosts reported by ruptime.
1552
COMPREPLY+=( $( compgen -W \
1553
"$( ruptime 2>/dev/null | awk '{ print $1 }' )" -- "$cur" ) )
1366
1555
# Add results of normal hostname completion, unless
1367
1556
# `COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value.
1368
if [ -n "${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}" ]; then
1369
COMPREPLY=( "${COMPREPLY[@]}"
1557
if [[ -n ${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1} ]]; then
1370
1559
$( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" ) )
1452
1636
# A meta-command completion function for commands like sudo(8), which need to
1453
1637
# first complete on a command, then complete according to that command's own
1454
# completion definition - currently not quite foolproof (e.g. mount and umount
1455
# don't work properly), but still quite useful.
1638
# completion definition.
1457
1640
_command_offset()
1459
local cur func cline cspec noglob cmd i char_offset word_offset \
1460
_COMMAND_FUNC _COMMAND_FUNC_ARGS
1464
1642
# rewrite current completion context before invoking
1465
1643
# actual command completion
1467
1645
# find new first word position, then
1468
1646
# rewrite COMP_LINE and adjust COMP_POINT
1469
local first_word=${COMP_WORDS[$word_offset]}
1470
for (( i=0; i <= ${#COMP_LINE}; i++ )); do
1471
if [[ "${COMP_LINE:$i:${#first_word}}" == "$first_word" ]]; then
1647
local word_offset=$1 i j
1648
for (( i=0; i < $word_offset; i++ )); do
1649
for (( j=0; j <= ${#COMP_LINE}; j++ )); do
1650
[[ "$COMP_LINE" == "${COMP_WORDS[i]}"* ]] && break
1651
COMP_LINE=${COMP_LINE:1}
1654
COMP_LINE=${COMP_LINE#"${COMP_WORDS[i]}"}
1655
((COMP_POINT-=${#COMP_WORDS[i]}))
1476
COMP_LINE=${COMP_LINE:$char_offset}
1477
COMP_POINT=$(( COMP_POINT - $char_offset ))
1479
1658
# shift COMP_WORDS elements and adjust COMP_CWORD
1480
1659
for (( i=0; i <= COMP_CWORD - $word_offset; i++ )); do
1481
1660
COMP_WORDS[i]=${COMP_WORDS[i+$word_offset]}
1483
1662
for (( i; i <= COMP_CWORD; i++ )); do
1484
unset COMP_WORDS[i];
1486
COMP_CWORD=$(( $COMP_CWORD - $word_offset ))
1665
((COMP_CWORD -= $word_offset))
1489
1669
_get_comp_words_by_ref cur
1491
1671
if [[ $COMP_CWORD -eq 0 ]]; then
1492
_compopt_o_filenames
1493
COMPREPLY=( $( compgen -c -- "$cur" ) )
1673
compopt -o filenames
1674
COMPREPLY=( $( compgen -d -c -- "$cur" ) )
1495
cmd=${COMP_WORDS[0]}
1496
if complete -p ${cmd##*/} &>/dev/null; then
1497
cspec=$( complete -p ${cmd##*/} )
1498
if [ "${cspec#* -F }" != "$cspec" ]; then
1676
local cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]}
1677
local cspec=$( complete -p $cmd 2>/dev/null )
1679
# If we have no completion for $cmd yet, see if we have for basename
1680
if [[ ! $cspec && $cmd == */* ]]; then
1681
cspec=$( complete -p ${cmd##*/} 2>/dev/null )
1682
[[ $cspec ]] && compcmd=${cmd##*/}
1684
# If still nothing, just load it for the basename
1685
if [[ ! $cspec ]]; then
1687
_completion_loader $compcmd
1688
cspec=$( complete -p $compcmd 2>/dev/null )
1691
if [[ -n $cspec ]]; then
1692
if [[ ${cspec#* -F } != $cspec ]]; then
1499
1693
# complete -F <function>
1501
1695
# get function name
1696
local func=${cspec#*-F }
1503
1697
func=${func%% *}
1505
1699
if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
1580
1792
# makeinfo and texi2dvi are defined elsewhere.
1581
for i in a2ps awk bash bc bison cat colordiff cp csplit \
1582
curl cut date df diff dir du enscript env expand fmt fold gperf gprof \
1793
complete -F _longopt a2ps awk base64 bash bc bison cat colordiff cp csplit \
1794
cut date df diff dir du enscript env expand fmt fold gperf \
1583
1795
grep grub head indent irb ld ldd less ln ls m4 md5sum mkdir mkfifo mknod \
1584
1796
mv netstat nl nm objcopy objdump od paste patch pr ptx readelf rm rmdir \
1585
sed seq sha{,1,224,256,384,512}sum shar sort split strip tac tail tee \
1586
texindex touch tr uname unexpand uniq units vdir wc wget who; do
1587
have $i && complete -F _longopt -o default $i
1797
sed seq sha{,1,224,256,384,512}sum shar sort split strip sum tac tail tee \
1798
texindex touch tr uname unexpand uniq units vdir wc wget who
1591
1801
_filedir_xspec()
1597
_get_comp_words_by_ref cur
1803
local cur prev words cword
1804
_init_completion || return
1599
1806
_expand || return 0
1601
# get first exclusion compspec that matches this command
1602
xspec=$( awk "/^complete[ \t]+.*[ \t]${1##*/}([ \t]|\$)/ { print \$0; exit }" \
1603
"$BASH_COMPLETION" )
1604
# prune to leave nothing but the -X spec
1808
local IFS=$'\n' xspec=${_xspecs[${1##*/}]} tmp
1611
toks=( ${toks[@]-} $(
1612
1812
compgen -d -- "$(quote_readline "$cur")" | {
1613
1813
while read -r tmp; do
1614
# see long TODO comment in _filedir() --David
1615
1814
printf '%s\n' $tmp
1620
1819
# Munge xspec to contain uppercase version too
1820
# http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306
1621
1821
eval xspec="${xspec}"
1622
1822
local matchop=!
1623
1823
if [[ $xspec == !* ]]; then
1624
1824
xspec=${xspec#!}
1627
[[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
1628
xspec="$matchop($xspec|${xspec^^})" || \
1629
xspec="$matchop($xspec|$(printf %s $xspec | tr '[:lower:]' '[:upper:]'))"
1827
xspec="$matchop($xspec|${xspec^^})"
1631
toks=( ${toks[@]-} $(
1632
1830
eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | {
1633
1831
while read -r tmp; do
1634
[ -n $tmp ] && printf '%s\n' $tmp
1832
[[ -n $tmp ]] && printf '%s\n' $tmp
1639
[ ${#toks[@]} -ne 0 ] && _compopt_o_filenames
1640
COMPREPLY=( "${toks[@]}" )
1837
if [[ ${#toks[@]} -ne 0 ]]; then
1838
compopt -o filenames
1839
COMPREPLY=( "${toks[@]}" )
1642
list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' "$BASH_COMPLETION" | \
1643
# read exclusion compspecs
1647
# ignore compspecs that are commented out
1648
if [ "${line#\#}" != "$line" ]; then continue; fi
1649
line=${line%# START exclude*}
1650
line=${line%# FINISH exclude*}
1652
list=( "${list[@]}" $line )
1848
_xspecs[$cmd]=$xspec
1654
printf '%s ' "${list[@]}"
1657
# remove previous compspecs
1658
if [ ${#list[@]} -gt 0 ]; then
1659
eval complete -r ${list[@]}
1660
# install new compspecs
1661
eval complete -F _filedir_xspec "${list[@]}"
1665
# source completion directory definitions
1850
complete -F _filedir_xspec $@
1852
# bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510
1853
_install_xspec '!*.?(t)bz?(2)' bunzip2 bzcat pbunzip2 pbzcat lbunzip2 lbzcat
1854
_install_xspec '!*.@(zip|[ejsw]ar|exe|pk3|wsz|zargo|xpi|sxw|o[tx]t|od[fgpst]|epub|apk)' unzip zipinfo
1855
_install_xspec '*.Z' compress znew
1856
# zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510
1857
_install_xspec '!*.@(Z|[gGd]z|t[ag]z)' gunzip zcat unpigz
1858
_install_xspec '!*.Z' uncompress
1859
# lzcmp, lzdiff intentionally not here, see Debian: #455510
1860
_install_xspec '!*.@(tlz|lzma)' lzcat lzegrep lzfgrep lzgrep lzless lzmore unlzma
1861
_install_xspec '!*.@(?(t)xz|tlz|lzma)' unxz xzcat
1862
_install_xspec '!*.lrz' lrunzip
1863
_install_xspec '!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx)' ee
1864
_install_xspec '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|svg)' qiv
1865
_install_xspec '!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|?(e)ps)' xv
1866
_install_xspec '!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))' gv ggv kghostview
1867
_install_xspec '!*.@(dvi|DVI)?(.@(gz|Z|bz2))' xdvi kdvi
1868
_install_xspec '!*.dvi' dvips dviselect dvitype dvipdf advi dvipdfm dvipdfmx
1869
_install_xspec '!*.[pf]df' acroread gpdf xpdf
1870
_install_xspec '!*.@(?(e)ps|pdf)' kpdf
1871
_install_xspec '!*.@(okular|@(?(e|x)ps|?(E|X)PS|[pf]df|[PF]DF|dvi|DVI|cb[rz]|CB[RZ]|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|epub|EPUB|odt|ODT|fb?(2)|FB?(2)|mobi|MOBI|g3|G3|chm|CHM)?(.?(gz|GZ|bz2|BZ2)))' okular
1872
_install_xspec '!*.pdf' epdfview
1873
_install_xspec '!*.@(?(e)ps|pdf)' ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr
1874
_install_xspec '!*.texi*' makeinfo texi2html
1875
_install_xspec '!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi
1876
_install_xspec '!*.mp3' mpg123 mpg321 madplay
1877
_install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.part)' xine aaxine fbxine
1878
_install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp[234]|MP[234]|m4[pv]|M4[PV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.part)' kaffeine dragon
1879
_install_xspec '!*.@(avi|asf|wmv)' aviplay
1880
_install_xspec '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay
1881
_install_xspec '!*.@(mpg|mpeg|avi|mov|qt)' xanim
1882
_install_xspec '!*.@(og[ag]|m3u|flac|spx)' ogg123
1883
_install_xspec '!*.@(mp3|og[ag]|pls|m3u)' gqmpeg freeamp
1884
_install_xspec '!*.fig' xfig
1885
_install_xspec '!*.@(mid?(i)|cmf)' playmidi
1886
_install_xspec '!*.@(mid?(i)|rmi|rcp|[gr]36|g18|mod|xm|it|x3m|s[3t]m|kar)' timidity
1887
_install_xspec '!*.@(669|abc|am[fs]|d[bs]m|dmf|far|it|mdl|m[eo]d|mid?(i)|mt[2m]|okta|p[st]m|s[3t]m|ult|umx|wav|xm)' modplugplay modplug123
1888
_install_xspec '*.@(o|so|so.!(conf|*/*)|a|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)' vi vim gvim rvim view rview rgvim rgview gview emacs xemacs sxemacs kate kwrite
1889
_install_xspec '!*.@(zip|z|gz|tgz)' bzme
1890
# konqueror not here on purpose, it's more than a web/html browser
1891
_install_xspec '!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))' netscape mozilla lynx opera galeon dillo elinks amaya firefox mozilla-firefox iceweasel google-chrome chromium-browser epiphany
1892
_install_xspec '!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|?(f)odt|ott|odm)' oowriter
1893
_install_xspec '!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|?(f)odp|otp)' ooimpress
1894
_install_xspec '!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|?(f)ods|ots)' oocalc
1895
_install_xspec '!*.@(sxd|std|sda|sdd|?(f)odg|otg)' oodraw
1896
_install_xspec '!*.@(sxm|smf|mml|odf)' oomath
1897
_install_xspec '!*.odb' oobase
1898
_install_xspec '!*.[rs]pm' rpm2cpio
1899
_install_xspec '!*.aux' bibtex
1900
_install_xspec '!*.po' poedit gtranslator kbabel lokalize
1901
_install_xspec '!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])' harbour gharbour hbpp
1902
_install_xspec '!*.[Hh][Rr][Bb]' hbrun
1903
_install_xspec '!*.ly' lilypond ly2dvi
1904
_install_xspec '!*.@(dif?(f)|?(d)patch)?(.@([gx]z|bz2|lzma))' cdiff
1905
_install_xspec '!@(*.@(ks|jks|jceks|p12|pfx|bks|ubr|gkr|cer|crt|cert|p7b|pkipath|pem|p10|csr|crl)|cacerts)' portecle
1906
_install_xspec '!*.@(mp[234c]|og[ag]|@(fl|a)ac|m4[abp]|spx|tta|w?(a)v|wma|aif?(f)|asf|ape)' kid3 kid3-qt
1907
unset -f _install_xspec
1909
# Minimal completion to use as fallback in _completion_loader.
1912
local cur prev words cword split
1913
_init_completion -s || return
1917
# Complete the empty string to allow completion of '>', '>>', and '<'
1918
# http://lists.gnu.org/archive/html/bug-bash/2012-01/msg00045.html
1919
complete -F _minimal ''
1922
# set up dynamic completion loading
1923
_completion_loader()
1925
local compdir=./completions
1926
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
1929
. "$compdir/${1##*/}" &>/dev/null && return 124
1931
# Need to define *something*, otherwise there will be no completion at all.
1932
complete -F _minimal "$1" && return 124
1934
complete -D -F _completion_loader
1936
# Function for loading and calling functions from dynamically loaded
1937
# completion files that may not have been sourced yet.
1938
# @param $1 completion file to load function from in case it is missing
1939
# @param $2... function and its arguments
1945
declare -F $1 &>/dev/null || {
1946
local compdir=./completions
1947
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"
1948
. "$compdir/$srcfile"
1953
# source compat completion directory definitions
1666
1954
if [[ -d $BASH_COMPLETION_COMPAT_DIR && -r $BASH_COMPLETION_COMPAT_DIR && \
1667
1955
-x $BASH_COMPLETION_COMPAT_DIR ]]; then
1668
1956
for i in $(LC_ALL=C command ls "$BASH_COMPLETION_COMPAT_DIR"); do
1669
1957
i=$BASH_COMPLETION_COMPAT_DIR/$i
1670
[[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)|Makefile*) \
1671
&& -f $i && -r $i ]] && . "$i"
1674
if [[ $BASH_COMPLETION_DIR != $BASH_COMPLETION_COMPAT_DIR && \
1675
-d $BASH_COMPLETION_DIR && -r $BASH_COMPLETION_DIR && \
1676
-x $BASH_COMPLETION_DIR ]]; then
1677
for i in $(LC_ALL=C command ls "$BASH_COMPLETION_DIR"); do
1678
i=$BASH_COMPLETION_DIR/$i
1679
[[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)|Makefile*) \
1680
&& -f $i && -r $i ]] && . "$i"
1958
[[ ${i##*/} != @($_backup_glob|Makefile*|$_blacklist_glob) \
1959
&& -f $i && -r $i ]] && . "$i"
1962
unset i _blacklist_glob
1685
1964
# source user completion file
1686
[[ $BASH_COMPLETION != ~/.bash_completion && -r ~/.bash_completion ]] \
1965
[[ ${BASH_SOURCE[0]} != ~/.bash_completion && -r ~/.bash_completion ]] \
1687
1966
&& . ~/.bash_completion
1689
unset UNAME USERLAND have
1691
1970
set $BASH_COMPLETION_ORIGINAL_V_VALUE
1692
1971
unset BASH_COMPLETION_ORIGINAL_V_VALUE
1695
# mode: shell-script
1696
# sh-basic-offset: 4
1697
# sh-indent-comment: t
1698
# indent-tabs-mode: nil
1700
1973
# ex: ts=4 sw=4 et filetype=sh