Lines 12-46
Link Here
|
12 |
# |
12 |
# |
13 |
_genlop() |
13 |
_genlop() |
14 |
{ |
14 |
{ |
15 |
local cur grepcmd sedcmd systemactions setsma setbig portagedir origdir |
15 |
local cur grepcmd sedcmd systemactions setsma setbig portagedir origdir args |
16 |
|
16 |
|
17 |
origdir="${PWD}" |
17 |
origdir="${PWD}" |
18 |
COMPREPLY=() |
18 |
COMPREPLY=() |
19 |
portagedir="$( (source /etc/make.globals |
19 |
portagedir="$( (source /etc/make.globals |
20 |
source /etc/make.conf |
20 |
source /etc/make.conf |
21 |
echo ${PORTDIR}) )" |
21 |
echo ${PORTDIR}) )" |
22 |
if [ -z "${portagedir}" ]; then |
22 |
if [[ -z "${portagedir}" ]]; then |
23 |
portagedir=/usr/portage |
23 |
portagedir="/usr/portage" |
24 |
fi |
24 |
fi |
25 |
cur="${COMP_WORDS[COMP_CWORD]}" |
25 |
cur="${COMP_WORDS[COMP_CWORD]}" |
26 |
|
26 |
|
27 |
cd "${portagedir}" |
27 |
builtin cd "${portagedir}" |
28 |
grepcmd="grep -E ^${cur}.*" |
28 |
grepcmd="grep -E ^${cur}.*" |
29 |
sedcmd="sed -e /^[^-]*$/d" |
29 |
sedcmd="sed -e /^[^-]*$/d" |
30 |
case "$cur" in |
30 |
case "${cur}" in |
31 |
-*) |
31 |
-*) |
32 |
COMPREPLY=( $( compgen -W '--current --file --help \ |
32 |
args='-c -e -f -h -i -g -l -n -p -r -s -S -t -u -v' |
33 |
--info --gmt --list --nocolor --pretend --rsync \ |
33 |
args="${args} --current --date --file --gmt --help \ |
34 |
--search --time --unmerge --version' -- $cur ) ) |
34 |
--info --list --nocolor --pretend --rsync \ |
|
|
35 |
--search --time --unmerge --version" |
36 |
COMPREPLY=( $( compgen -W "${args}" -- ${cur} ) ) |
35 |
;; |
37 |
;; |
36 |
*) |
38 |
*) |
37 |
if [ "${cur}" ]; then |
39 |
if [[ "${cur}" ]]; then |
38 |
if [ $(echo "${cur}" | grep '/') ]; then |
40 |
if [[ $(echo "${cur}" | grep '/') ]]; then |
39 |
setbig=$(compgen -G "${cur}*" | ${sedcmd})"${systemactions}" |
41 |
setbig=$(compgen -G "${cur}*" | ${sedcmd})"${systemactions}" |
40 |
COMPREPLY=($(echo "${setbig}" | $grepcmd)) |
42 |
COMPREPLY=($(echo "${setbig}" | ${grepcmd})) |
41 |
else |
43 |
else |
42 |
setsma=$(compgen -S '/' -G "${cur}*" | ${sedcmd})"${systemactions}" |
44 |
setsma=$(compgen -S '/' -G "${cur}*" | ${sedcmd})"${systemactions}" |
43 |
if [ $(echo "${setsma}" | ${grepcmd} | grep '/' | wc -l) = 1 ]; then |
45 |
if [[ $(echo "${setsma}" | ${grepcmd} | grep '/' | wc -l) == 1 ]]; then |
44 |
setbig=$(compgen -G "*/*" | ${sedcmd})"${systemactions}" |
46 |
setbig=$(compgen -G "*/*" | ${sedcmd})"${systemactions}" |
45 |
COMPREPLY=($(echo "${setbig}" | ${grepcmd})) |
47 |
COMPREPLY=($(echo "${setbig}" | ${grepcmd})) |
46 |
else |
48 |
else |
Lines 54-60
Link Here
|
54 |
;; |
56 |
;; |
55 |
esac |
57 |
esac |
56 |
|
58 |
|
57 |
cd "${origdir}" |
59 |
builtin cd "${origdir}" |
58 |
return 0 |
60 |
return 0 |
59 |
} |
61 |
} |
60 |
complete -o default -F _genlop genlop |
62 |
complete -o default -F _genlop genlop |