Lines 23-40
Link Here
|
23 |
# -d, -f, and -X pattern without missing directories. |
23 |
# -d, -f, and -X pattern without missing directories. |
24 |
local c=${COMP_WORDS[COMP_CWORD]} |
24 |
local c=${COMP_WORDS[COMP_CWORD]} |
25 |
local a="${COMP_LINE}" |
25 |
local a="${COMP_LINE}" |
26 |
local e s g=0 cd dc t="" |
26 |
local e s cd dc t="" |
27 |
local IFS |
27 |
local IFS |
28 |
|
28 |
|
29 |
shopt -q extglob && g=1 |
|
|
30 |
test $g -eq 0 && shopt -s extglob |
31 |
# Don't be fooled by the bash parser if extglob is off by default |
32 |
cd='*-?(c)d*' |
29 |
cd='*-?(c)d*' |
33 |
dc='*-d?(c)*' |
30 |
dc='*-d?(c)*' |
34 |
|
31 |
|
35 |
case "${1##*/}" in |
32 |
case "${1##*/}" in |
36 |
@BASH_COMPLETION_SUFFIXES_CHECKS@ |
33 |
@BASH_COMPLETION_SUFFIXES_CHECKS@ |
37 |
*) e='!*' |
34 |
*) e='@()' |
38 |
esac |
35 |
esac |
39 |
|
36 |
|
40 |
case "$(complete -p ${1##*/} 2> /dev/null)" in |
37 |
case "$(complete -p ${1##*/} 2> /dev/null)" in |
Lines 52-86
Link Here
|
52 |
\$\{*\}) eval COMPREPLY=\(${c}\) ;; |
49 |
\$\{*\}) eval COMPREPLY=\(${c}\) ;; |
53 |
\$\{*) COMPREPLY=($(compgen -v -P '${' -S '}' -- ${c#??})) ;; |
50 |
\$\{*) COMPREPLY=($(compgen -v -P '${' -S '}' -- ${c#??})) ;; |
54 |
\$*) COMPREPLY=($(compgen -v -P '$' -- ${c#?})) ;; |
51 |
\$*) COMPREPLY=($(compgen -v -P '$' -- ${c#?})) ;; |
55 |
\~*/*) COMPREPLY=($(compgen -f -X "$e" -- ${c})) ;; |
52 |
\~*) cur="${COMP_WORDS[COMP_CWORD]}"; _filedir "$e" ;; |
56 |
\~*) COMPREPLY=($(compgen -u ${s} -- ${c})) ;; |
|
|
57 |
*@*) COMPREPLY=($(compgen -A hostname -P '@' -S ':' -- ${c#*@})) ;; |
53 |
*@*) COMPREPLY=($(compgen -A hostname -P '@' -S ':' -- ${c#*@})) ;; |
58 |
*[*?[]*) COMPREPLY=($(compgen -G "${c}")) ;; |
54 |
*[*?[]*) COMPREPLY=($(compgen -G "${c}")) ;; |
59 |
*[?*+\!@]\(*\)*) |
55 |
*[?*+\!@]\(*\)*) |
60 |
if test $g -eq 0 ; then |
56 |
cur="${COMP_WORDS[COMP_CWORD]}"; _filedir "$e" ;; |
61 |
COMPREPLY=($(compgen -f -X "$e" -- $c)) |
|
|
62 |
test $g -eq 0 && shopt -u extglob |
63 |
return |
64 |
fi |
65 |
COMPREPLY=($(compgen -G "${c}")) ;; |
66 |
*) |
57 |
*) |
67 |
if test "$c" = ".." ; then |
58 |
cur="${COMP_WORDS[COMP_CWORD]}"; _filedir "$e" ;; |
68 |
COMPREPLY=($(compgen -d -X "$e" -S / ${_nosp} -- $c)) |
|
|
69 |
else |
70 |
for s in $(compgen -f -X "$e" -- $c) ; do |
71 |
if test -d $s ; then |
72 |
COMPREPLY=(${COMPREPLY[@]} $(compgen -f -X "$e" -S / -- $s)) |
73 |
elif test -z "$t" ; then |
74 |
COMPREPLY=(${COMPREPLY[@]} $s) |
75 |
else |
76 |
case "$(file -b $s 2> /dev/null)" in |
77 |
$t) COMPREPLY=(${COMPREPLY[@]} $s) ;; |
78 |
esac |
79 |
fi |
80 |
done |
81 |
fi ;; |
82 |
esac |
59 |
esac |
83 |
test $g -eq 0 && shopt -u extglob |
|
|
84 |
} |
60 |
} |
85 |
|
61 |
|
86 |
|
62 |
|