Lines 5-19
Link Here
|
5 |
# Copyright 1999-2009 Gentoo Foundation |
5 |
# Copyright 1999-2009 Gentoo Foundation |
6 |
# Distributed under the terms of the GNU General Public License, v2 or later |
6 |
# Distributed under the terms of the GNU General Public License, v2 or later |
7 |
|
7 |
|
8 |
# also defined in bash_completion proper however, will produce command |
|
|
9 |
# not found warnings when this is only enabled "locally" so we define it |
10 |
# here as well. |
11 |
have() |
12 |
{ |
13 |
unset -v have |
14 |
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 >&/dev/null && have="yes" |
15 |
} |
16 |
|
17 |
# |
8 |
# |
18 |
# Retrieve PORTDIR/PORTDIR_OVERLAY location from user's make.conf or, if it |
9 |
# Retrieve PORTDIR/PORTDIR_OVERLAY location from user's make.conf or, if it |
19 |
# is not defined there, from make.globals. |
10 |
# is not defined there, from make.globals. |
Lines 169-175
_pkgname()
Link Here
|
169 |
# |
160 |
# |
170 |
# This is an helper function for completion of "-o <list>" / "--option=<list>" |
161 |
# This is an helper function for completion of "-o <list>" / "--option=<list>" |
171 |
# kind of command lines options. |
162 |
# kind of command lines options. |
172 |
# |
163 |
# |
173 |
# Usage: _list_compgen <current> <sep> <item1>[<sep><item2> ...] |
164 |
# Usage: _list_compgen <current> <sep> <item1>[<sep><item2> ...] |
174 |
# - <current>: what we have so far on the command line |
165 |
# - <current>: what we have so far on the command line |
175 |
# - <sep>: the separator character used in lists |
166 |
# - <sep>: the separator character used in lists |
Lines 177-188
_pkgname()
Link Here
|
177 |
# Returns: the function outputs each possible completion (one per line), |
168 |
# Returns: the function outputs each possible completion (one per line), |
178 |
# and returns 0. Typical usage is COMPREPLY=($(_list_compgen ...)). |
169 |
# and returns 0. Typical usage is COMPREPLY=($(_list_compgen ...)). |
179 |
# |
170 |
# |
180 |
# Note: items must not contain the <sep> character (no backslash escaping has |
171 |
# Note: items must not contain the <sep> character (no backslash escaping has |
181 |
# been implemented). |
172 |
# been implemented). |
182 |
# |
173 |
# |
183 |
_list_compgen() |
174 |
_list_compgen() |
184 |
{ |
175 |
{ |
185 |
# Read the three parameters. |
176 |
# Read the three parameters. |
186 |
local current="${1}" ; shift |
177 |
local current="${1}" ; shift |
187 |
local sep="${1}" ; shift |
178 |
local sep="${1}" ; shift |
188 |
local items="${*}" |
179 |
local items="${*}" |
Lines 193-199
_list_compgen()
Link Here
|
193 |
# Setting it to 0 means "never list anything" (only suggest <sep>). |
184 |
# Setting it to 0 means "never list anything" (only suggest <sep>). |
194 |
# Setting it to a positive value N means "list up to N possible items, and |
185 |
# Setting it to a positive value N means "list up to N possible items, and |
195 |
# only suggest <sep> if there are more". |
186 |
# only suggest <sep> if there are more". |
196 |
# It is probably not worth a parameter, thus it will defaults to my |
187 |
# It is probably not worth a parameter, thus it will defaults to my |
197 |
# prefered setting (1) if not already defined in the environment. |
188 |
# prefered setting (1) if not already defined in the environment. |
198 |
local max_others_number=${max_others_number:-1} |
189 |
local max_others_number=${max_others_number:-1} |
199 |
|
190 |
|
Lines 309-315
_list_compgen()
Link Here
|
309 |
# |
300 |
# |
310 |
# emerge completion command |
301 |
# emerge completion command |
311 |
# |
302 |
# |
312 |
have emerge && { |
|
|
313 |
_emerge() |
303 |
_emerge() |
314 |
{ |
304 |
{ |
315 |
local c cur prev curword numwords opts cond prepend |
305 |
local c cur prev curword numwords opts cond prepend |
Lines 480-486
_emerge()
Link Here
|
480 |
[[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg |
470 |
[[ -z "${COMPREPLY}" ]] && _pkgname_only ${cur} @GENTOO_PORTAGE_EPREFIX@/var/db/pkg |
481 |
return 0 |
471 |
return 0 |
482 |
fi |
472 |
fi |
483 |
|
473 |
|
484 |
# Check for conditional. |
474 |
# Check for conditional. |
485 |
cond="${cur%%[A-Za-z0-9]*}" |
475 |
cond="${cur%%[A-Za-z0-9]*}" |
486 |
cur="${cur:${#cond}}" |
476 |
cur="${cur:${#cond}}" |
Lines 490-496
_emerge()
Link Here
|
490 |
else |
480 |
else |
491 |
c="${cond}" |
481 |
c="${cond}" |
492 |
fi |
482 |
fi |
493 |
|
483 |
|
494 |
# Handle cases where a conditional is specified. |
484 |
# Handle cases where a conditional is specified. |
495 |
if [[ -n "${cond}" ]]; then |
485 |
if [[ -n "${cond}" ]]; then |
496 |
if [[ -n "${cur}" ]]; then |
486 |
if [[ -n "${cur}" ]]; then |
Lines 523-529
_emerge()
Link Here
|
523 |
|
513 |
|
524 |
words=$(echo -ne ${w} | sort | uniq) |
514 |
words=$(echo -ne ${w} | sort | uniq) |
525 |
COMPREPLY=( ${words} ) |
515 |
COMPREPLY=( ${words} ) |
526 |
|
516 |
|
527 |
# Complete on the specific versions (if appropriate). |
517 |
# Complete on the specific versions (if appropriate). |
528 |
# TODO - see if we can use _pkgname |
518 |
# TODO - see if we can use _pkgname |
529 |
if [[ ${#COMPREPLY[@]} -le 1 ]]; then |
519 |
if [[ ${#COMPREPLY[@]} -le 1 ]]; then |
Lines 583-589
_emerge()
Link Here
|
583 |
done)" |
573 |
done)" |
584 |
COMPREPLY=($(compgen -W "${words}" -- "${cur}")) |
574 |
COMPREPLY=($(compgen -W "${words}" -- "${cur}")) |
585 |
fi |
575 |
fi |
586 |
|
576 |
|
587 |
# If all else fails, try to complete on package names without the |
577 |
# If all else fails, try to complete on package names without the |
588 |
# category being specified. |
578 |
# category being specified. |
589 |
if [[ -z "${COMPREPLY}" ]]; then |
579 |
if [[ -z "${COMPREPLY}" ]]; then |
Lines 706-719
_emerge()
Link Here
|
706 |
fi |
696 |
fi |
707 |
|
697 |
|
708 |
return 0 |
698 |
return 0 |
709 |
} |
699 |
} && |
710 |
complete -o filenames -F _emerge emerge |
700 |
complete -o filenames -F _emerge emerge |
711 |
} |
|
|
712 |
|
701 |
|
713 |
# |
702 |
# |
714 |
# ebuild completion command |
703 |
# ebuild completion command |
715 |
# |
704 |
# |
716 |
have ebuild && { |
|
|
717 |
_ebuild() |
705 |
_ebuild() |
718 |
{ |
706 |
{ |
719 |
local cur opts |
707 |
local cur opts |
Lines 736-774
_ebuild()
Link Here
|
736 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
724 |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
737 |
fi |
725 |
fi |
738 |
return 0 |
726 |
return 0 |
739 |
} |
727 |
} && |
740 |
complete -o filenames -F _ebuild ebuild |
728 |
complete -o filenames -F _ebuild ebuild |
741 |
} |
|
|
742 |
|
743 |
# |
744 |
# Gentoo init.d completion |
745 |
# |
746 |
|
747 |
_gentoo_style_init() |
748 |
{ |
749 |
local script="${COMP_WORDS[0]}" |
750 |
local cur="${COMP_WORDS[$COMP_CWORD]}" |
751 |
|
752 |
if [[ ( -f "${script}" || -h "${script}" ) && -r "${script}" ]] \ |
753 |
&& [[ "${script}" != *.sh ]] \ |
754 |
&& [[ "$(head -n 1 "${script}")" = "#!/sbin/runscript" ]] |
755 |
then |
756 |
[[ $COMP_CWORD -gt 1 ]] && return 1 |
757 |
COMPREPLY=($(opts="start stop status restart pause zap ineed needsme iuse usesme broken"; \ |
758 |
eval "$(grep '^opts=' "${script}")"; echo "${opts}")) |
759 |
[[ -n "$COMPREPLY" ]] || COMPREPLY=(start stop restart zap) |
760 |
COMPREPLY=($(compgen -W "${COMPREPLY[*]}" -- "${cur}")) |
761 |
else |
762 |
COMPREPLY=($(compgen -o default -- "${cur}")) |
763 |
fi |
764 |
return 0 |
765 |
} |
766 |
complete -F _gentoo_style_init @GENTOO_PORTAGE_EPREFIX@/etc/init.d/* |
767 |
|
729 |
|
768 |
# |
730 |
# |
769 |
# rc completion command |
731 |
# rc completion command |
770 |
# |
732 |
# |
771 |
have rc && { |
|
|
772 |
_rc() |
733 |
_rc() |
773 |
{ |
734 |
{ |
774 |
local cur |
735 |
local cur |
Lines 778-791
_rc()
Link Here
|
778 |
COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur)) |
739 |
COMPREPLY=($(compgen -W "$(for i in @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/*; do echo ${i##*/}; done)" -- $cur)) |
779 |
fi |
740 |
fi |
780 |
return 0 |
741 |
return 0 |
781 |
} |
742 |
} && |
782 |
complete -F _rc rc |
743 |
complete -F _rc rc |
783 |
} |
|
|
784 |
|
744 |
|
785 |
# |
745 |
# |
786 |
# rc-status completion command |
746 |
# rc-status completion command |
787 |
# |
747 |
# |
788 |
have rc-status && { |
|
|
789 |
_rcstatus() |
748 |
_rcstatus() |
790 |
{ |
749 |
{ |
791 |
local cur |
750 |
local cur |
Lines 802-815
_rcstatus()
Link Here
|
802 |
unset COMPREPLY |
761 |
unset COMPREPLY |
803 |
fi |
762 |
fi |
804 |
return 0 |
763 |
return 0 |
805 |
} |
764 |
} && |
806 |
complete -F _rcstatus rc-status |
765 |
complete -F _rcstatus rc-status |
807 |
} |
|
|
808 |
|
766 |
|
809 |
# |
767 |
# |
810 |
# rc-update completion command |
768 |
# rc-update completion command |
811 |
# |
769 |
# |
812 |
have rc-update && { |
|
|
813 |
_rcupdate() |
770 |
_rcupdate() |
814 |
{ |
771 |
{ |
815 |
local cur show |
772 |
local cur show |
Lines 838-851
_rcupdate()
Link Here
|
838 |
fi |
795 |
fi |
839 |
fi |
796 |
fi |
840 |
return 0 |
797 |
return 0 |
841 |
} |
798 |
} && |
842 |
complete -F _rcupdate rc-update |
799 |
complete -F _rcupdate rc-update |
843 |
} |
|
|
844 |
|
800 |
|
845 |
# |
801 |
# |
846 |
# gcc-config completion command |
802 |
# gcc-config completion command |
847 |
# |
803 |
# |
848 |
have gcc-config && { |
|
|
849 |
_gcc_config() { |
804 |
_gcc_config() { |
850 |
local cur prev opts |
805 |
local cur prev opts |
851 |
COMPREPLY=() |
806 |
COMPREPLY=() |
Lines 879-892
_gcc_config() {
Link Here
|
879 |
$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) ) |
834 |
$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) ) |
880 |
;; |
835 |
;; |
881 |
esac |
836 |
esac |
882 |
} |
837 |
} && |
883 |
complete -F _gcc_config gcc-config |
838 |
complete -F _gcc_config gcc-config |
884 |
} |
|
|
885 |
|
839 |
|
886 |
# |
840 |
# |
887 |
# distcc-config completion command |
841 |
# distcc-config completion command |
888 |
# |
842 |
# |
889 |
have distcc-config && { |
|
|
890 |
_distccconfig() |
843 |
_distccconfig() |
891 |
{ |
844 |
{ |
892 |
local cur curword numwords opts |
845 |
local cur curword numwords opts |
Lines 916-929
_distccconfig()
Link Here
|
916 |
fi |
869 |
fi |
917 |
COMPREPLY=($(compgen -W "${opts}" | grep ^$cur)) |
870 |
COMPREPLY=($(compgen -W "${opts}" | grep ^$cur)) |
918 |
return 0 |
871 |
return 0 |
919 |
} |
872 |
} && |
920 |
complete -F _distccconfig distcc-config |
873 |
complete -F _distccconfig distcc-config |
921 |
} |
|
|
922 |
|
874 |
|
923 |
# |
875 |
# |
924 |
# java-config completion command |
876 |
# java-config completion command |
925 |
# |
877 |
# |
926 |
have java-config && { |
|
|
927 |
_javaconfig() |
878 |
_javaconfig() |
928 |
{ |
879 |
{ |
929 |
local cur prev curword numwords opts args arg spec flag sedcmd grepcmd |
880 |
local cur prev curword numwords opts args arg spec flag sedcmd grepcmd |
Lines 1070-1083
_javaconfig()
Link Here
|
1070 |
fi |
1021 |
fi |
1071 |
COMPREPLY=($(compgen $nospace -W "${opts}" -- ${cur})) |
1022 |
COMPREPLY=($(compgen $nospace -W "${opts}" -- ${cur})) |
1072 |
return 0 |
1023 |
return 0 |
1073 |
} |
1024 |
} && |
1074 |
complete $nospace -F _javaconfig java-config |
1025 |
complete $nospace -F _javaconfig java-config |
1075 |
} |
|
|
1076 |
|
1026 |
|
1077 |
# |
1027 |
# |
1078 |
# browser-config completion command |
1028 |
# browser-config completion command |
1079 |
# |
1029 |
# |
1080 |
have browser-config && { |
|
|
1081 |
_browserconfig() |
1030 |
_browserconfig() |
1082 |
{ |
1031 |
{ |
1083 |
local cur prev |
1032 |
local cur prev |
Lines 1097-1105
_browserconfig()
Link Here
|
1097 |
unset COMPREPLY |
1046 |
unset COMPREPLY |
1098 |
fi |
1047 |
fi |
1099 |
return 0 |
1048 |
return 0 |
1100 |
} |
1049 |
} && |
1101 |
complete -F _browserconfig browser-config |
1050 |
complete -F _browserconfig browser-config |
1102 |
} |
|
|
1103 |
|
1051 |
|
1104 |
# |
1052 |
# |
1105 |
# Helper routine for the subcommand 'meta' of 'equery' |
1053 |
# Helper routine for the subcommand 'meta' of 'equery' |
Lines 1122-1128
_equery_meta()
Link Here
|
1122 |
# |
1070 |
# |
1123 |
# Bash completion for the Gentoo 'equery' command |
1071 |
# Bash completion for the Gentoo 'equery' command |
1124 |
# |
1072 |
# |
1125 |
have equery && { |
|
|
1126 |
_equery() |
1073 |
_equery() |
1127 |
{ |
1074 |
{ |
1128 |
local cur prev mode portdir i j |
1075 |
local cur prev mode portdir i j |
Lines 1157-1163
_equery()
Link Here
|
1157 |
esac |
1104 |
esac |
1158 |
;; |
1105 |
;; |
1159 |
c?(hanges)) |
1106 |
c?(hanges)) |
1160 |
# Complete package name only if it is not yet supplied. |
1107 |
# Complete package name only if it is not yet supplied. |
1161 |
if [[ ${prev} == ${mode} ]]; then |
1108 |
if [[ ${prev} == ${mode} ]]; then |
1162 |
case $cur in |
1109 |
case $cur in |
1163 |
-*) |
1110 |
-*) |
Lines 1186-1192
_equery()
Link Here
|
1186 |
return 0 |
1133 |
return 0 |
1187 |
fi |
1134 |
fi |
1188 |
case $cur in |
1135 |
case $cur in |
1189 |
--f*) |
1136 |
--f*) |
1190 |
# don't handle --filter= with others to avoid space after the "=" |
1137 |
# don't handle --filter= with others to avoid space after the "=" |
1191 |
COMPREPLY=($(compgen -P "--filter=" \ |
1138 |
COMPREPLY=($(compgen -P "--filter=" \ |
1192 |
-W "dir obj sym dev fifo path conf cmd doc man info")) |
1139 |
-W "dir obj sym dev fifo path conf cmd doc man info")) |
Lines 1317-1323
_equery()
Link Here
|
1317 |
*) |
1264 |
*) |
1318 |
case $prev in |
1265 |
case $prev in |
1319 |
-a|--all-packages) |
1266 |
-a|--all-packages) |
1320 |
# Complete on all package names. |
1267 |
# Complete on all package names. |
1321 |
_pkgname -A $cur |
1268 |
_pkgname -A $cur |
1322 |
;; |
1269 |
;; |
1323 |
*) |
1270 |
*) |
Lines 1389-1403
_equery()
Link Here
|
1389 |
;; |
1336 |
;; |
1390 |
esac |
1337 |
esac |
1391 |
return 0 |
1338 |
return 0 |
1392 |
} |
1339 |
} && |
1393 |
complete -F _equery equery |
1340 |
complete -F _equery equery |
1394 |
} |
|
|
1395 |
|
1341 |
|
1396 |
# |
1342 |
# |
1397 |
# epkginfo completion |
1343 |
# epkginfo completion |
1398 |
# |
1344 |
# |
1399 |
|
1345 |
|
1400 |
have epkginfo && { |
|
|
1401 |
_epkginfo() |
1346 |
_epkginfo() |
1402 |
{ |
1347 |
{ |
1403 |
local cur prev |
1348 |
local cur prev |
Lines 1411-1425
_epkginfo()
Link Here
|
1411 |
fi |
1356 |
fi |
1412 |
|
1357 |
|
1413 |
return 0 |
1358 |
return 0 |
1414 |
} |
1359 |
} && |
1415 |
complete -F _epkginfo epkginfo |
1360 |
complete -F _epkginfo epkginfo |
1416 |
} |
|
|
1417 |
|
1361 |
|
1418 |
# |
1362 |
# |
1419 |
# ekeyword completion |
1363 |
# ekeyword completion |
1420 |
# |
1364 |
# |
1421 |
|
1365 |
|
1422 |
have ekeyword && { |
|
|
1423 |
_ekeyword() |
1366 |
_ekeyword() |
1424 |
{ |
1367 |
{ |
1425 |
local cur portdir archl_s archl_u archl_r archl_m arch |
1368 |
local cur portdir archl_s archl_u archl_r archl_m arch |
Lines 1451-1465
_ekeyword()
Link Here
|
1451 |
_filedir 'ebuild' |
1394 |
_filedir 'ebuild' |
1452 |
;; |
1395 |
;; |
1453 |
esac |
1396 |
esac |
1454 |
} |
1397 |
} && |
1455 |
complete -o filenames -F _ekeyword ekeyword |
1398 |
complete -o filenames -F _ekeyword ekeyword |
1456 |
} |
|
|
1457 |
|
1399 |
|
1458 |
# |
1400 |
# |
1459 |
# portageq completion |
1401 |
# portageq completion |
1460 |
# |
1402 |
# |
1461 |
|
1403 |
|
1462 |
have portageq && { |
|
|
1463 |
_portageq() { |
1404 |
_portageq() { |
1464 |
local cur prev opts |
1405 |
local cur prev opts |
1465 |
COMPREPLY=() |
1406 |
COMPREPLY=() |
Lines 1482-1488
_portageq() {
Link Here
|
1482 |
pkgdir \ |
1423 |
pkgdir \ |
1483 |
portdir_overlay \ |
1424 |
portdir_overlay \ |
1484 |
distdir" |
1425 |
distdir" |
1485 |
|
1426 |
|
1486 |
if [[ $COMP_CWORD -eq 1 ]] ; then |
1427 |
if [[ $COMP_CWORD -eq 1 ]] ; then |
1487 |
# would always be correct, but it's pretty slow... |
1428 |
# would always be correct, but it's pretty slow... |
1488 |
#COMPREPLY=($(compgen -W "$(portageq | grep '^ [[:lower:]]' | \ |
1429 |
#COMPREPLY=($(compgen -W "$(portageq | grep '^ [[:lower:]]' | \ |
Lines 1495-1516
_portageq() {
Link Here
|
1495 |
config*|vdb_path|gentoo_mirrors|*dir*) |
1436 |
config*|vdb_path|gentoo_mirrors|*dir*) |
1496 |
COMPREPLY=() |
1437 |
COMPREPLY=() |
1497 |
;; |
1438 |
;; |
1498 |
|
1439 |
|
1499 |
# this also isn't the fastest, but I welcome an alternative method |
1440 |
# this also isn't the fastest, but I welcome an alternative method |
1500 |
envvar) |
1441 |
envvar) |
1501 |
COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \ |
1442 |
COMPREPLY=($(compgen -W "$(env -i emerge -v --info | \ |
1502 |
sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur})) |
1443 |
sed -n -e '/^[[:upper:]].*=".*"/s/^\(.*\)=".*$/\1/p')" -- ${cur})) |
1503 |
;; |
1444 |
;; |
1504 |
|
1445 |
|
1505 |
*v@(isible|ersion)|match) |
1446 |
*v@(isible|ersion)|match) |
1506 |
COMPREPLY=($(compgen $nospace -W '/' -- $cur)) |
1447 |
COMPREPLY=($(compgen $nospace -W '/' -- $cur)) |
1507 |
;; |
1448 |
;; |
1508 |
|
1449 |
|
1509 |
# $prev is a path, so complete on category/package |
1450 |
# $prev is a path, so complete on category/package |
1510 |
*/*) |
1451 |
*/*) |
1511 |
local x a=0 |
1452 |
local x a=0 |
1512 |
for x in ${COMP_WORDS[@]} ; do |
1453 |
for x in ${COMP_WORDS[@]} ; do |
1513 |
# This is the only one |
1454 |
# This is the only one |
1514 |
if [[ "${x}" == "all_best_visible" ]] ; then |
1455 |
if [[ "${x}" == "all_best_visible" ]] ; then |
1515 |
a=1 |
1456 |
a=1 |
1516 |
break |
1457 |
break |
Lines 1530-1547
_portageq() {
Link Here
|
1530 |
_pkgname -A $cur |
1471 |
_pkgname -A $cur |
1531 |
# fi |
1472 |
# fi |
1532 |
fi |
1473 |
fi |
1533 |
;; |
1474 |
;; |
1534 |
esac |
1475 |
esac |
1535 |
} |
1476 |
} && |
1536 |
|
|
|
1537 |
complete -F _portageq portageq |
1477 |
complete -F _portageq portageq |
1538 |
} |
|
|
1539 |
|
1478 |
|
1540 |
# |
1479 |
# |
1541 |
# webapp-config completion |
1480 |
# webapp-config completion |
1542 |
# |
1481 |
# |
1543 |
|
1482 |
|
1544 |
have webapp-config && { |
|
|
1545 |
_webapp_complete_appver() |
1483 |
_webapp_complete_appver() |
1546 |
{ |
1484 |
{ |
1547 |
local x proot ibase cur="$2" |
1485 |
local x proot ibase cur="$2" |
Lines 1561-1567
_webapp_complete_appver()
Link Here
|
1561 |
fi ; \ |
1499 |
fi ; \ |
1562 |
done)" -- ${cur})) |
1500 |
done)" -- ${cur})) |
1563 |
;; |
1501 |
;; |
1564 |
|
1502 |
|
1565 |
# complete on uninstalled |
1503 |
# complete on uninstalled |
1566 |
uninstalled) |
1504 |
uninstalled) |
1567 |
COMPREPLY=($(compgen -W "$(\ |
1505 |
COMPREPLY=($(compgen -W "$(\ |
Lines 1572-1578
_webapp_complete_appver()
Link Here
|
1572 |
fi ; \ |
1510 |
fi ; \ |
1573 |
done)" -- ${cur})) |
1511 |
done)" -- ${cur})) |
1574 |
;; |
1512 |
;; |
1575 |
|
1513 |
|
1576 |
# all |
1514 |
# all |
1577 |
all) |
1515 |
all) |
1578 |
COMPREPLY=($(compgen -W "$(\ |
1516 |
COMPREPLY=($(compgen -W "$(\ |
Lines 1580-1586
_webapp_complete_appver()
Link Here
|
1580 |
[[ -d "${x}" ]] && echo "${x##*/}" ; \ |
1518 |
[[ -d "${x}" ]] && echo "${x##*/}" ; \ |
1581 |
done)" -- ${cur})) |
1519 |
done)" -- ${cur})) |
1582 |
;; |
1520 |
;; |
1583 |
|
1521 |
|
1584 |
# complete on version |
1522 |
# complete on version |
1585 |
*) |
1523 |
*) |
1586 |
[[ -d "${proot}/$1" ]] || return 1 |
1524 |
[[ -d "${proot}/$1" ]] || return 1 |
Lines 1618-1624
_webapp_config()
Link Here
|
1618 |
COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur})) |
1556 |
COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur})) |
1619 |
return 0 |
1557 |
return 0 |
1620 |
fi |
1558 |
fi |
1621 |
|
1559 |
|
1622 |
case "${prev}" in |
1560 |
case "${prev}" in |
1623 |
--bug-report|-p|--pretend) |
1561 |
--bug-report|-p|--pretend) |
1624 |
COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur})) |
1562 |
COMPREPLY=($(compgen -W "${opts} ${actions}" -- ${cur})) |
Lines 1640-1650
_webapp_config()
Link Here
|
1640 |
--list-unused-installs) |
1578 |
--list-unused-installs) |
1641 |
_webapp_complete_appver uninstalled ${cur} |
1579 |
_webapp_complete_appver uninstalled ${cur} |
1642 |
;; |
1580 |
;; |
1643 |
|
1581 |
|
1644 |
--list-installs|--show-postinst) |
1582 |
--list-installs|--show-postinst) |
1645 |
_webapp_complete_appver all ${cur} |
1583 |
_webapp_complete_appver all ${cur} |
1646 |
;; |
1584 |
;; |
1647 |
|
1585 |
|
1648 |
# hrm... anyone know a better way to reliably do this? |
1586 |
# hrm... anyone know a better way to reliably do this? |
1649 |
-h|--host) |
1587 |
-h|--host) |
1650 |
local x |
1588 |
local x |
Lines 1653-1664
_webapp_config()
Link Here
|
1653 |
[[ -d "${x}" ]] && echo "${x##*/}" ; \ |
1591 |
[[ -d "${x}" ]] && echo "${x##*/}" ; \ |
1654 |
done)" -- ${cur})) |
1592 |
done)" -- ${cur})) |
1655 |
;; |
1593 |
;; |
1656 |
|
1594 |
|
1657 |
--virtual*) |
1595 |
--virtual*) |
1658 |
COMPREPLY=($(compgen -W "server-owned config-owned virtual" \ |
1596 |
COMPREPLY=($(compgen -W "server-owned config-owned virtual" \ |
1659 |
-- ${cur})) |
1597 |
-- ${cur})) |
1660 |
;; |
1598 |
;; |
1661 |
|
1599 |
|
1662 |
-d|--dir) |
1600 |
-d|--dir) |
1663 |
local host x i=0 |
1601 |
local host x i=0 |
1664 |
# see if --host has been specified, and if so, get the value |
1602 |
# see if --host has been specified, and if so, get the value |
Lines 1676-1682
_webapp_config()
Link Here
|
1676 |
eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \ |
1614 |
eval $(. @GENTOO_PORTAGE_EPREFIX@/etc/vhosts/webapp-config ; \ |
1677 |
echo host="${VHOST_HOSTNAME:-localhost}") |
1615 |
echo host="${VHOST_HOSTNAME:-localhost}") |
1678 |
fi |
1616 |
fi |
1679 |
|
1617 |
|
1680 |
COMPREPLY=($(compgen -W "$(\ |
1618 |
COMPREPLY=($(compgen -W "$(\ |
1681 |
for x in ${hostroot}${host}/* ; do \ |
1619 |
for x in ${hostroot}${host}/* ; do \ |
1682 |
[[ -d "${x}" ]] && echo "${x}" ; \ |
1620 |
[[ -d "${x}" ]] && echo "${x}" ; \ |
Lines 1698-1708
_webapp_config()
Link Here
|
1698 |
_webapp_complete_appver all ${cur} |
1636 |
_webapp_complete_appver all ${cur} |
1699 |
;; |
1637 |
;; |
1700 |
esac |
1638 |
esac |
1701 |
} |
1639 |
} && |
1702 |
complete -F _webapp_config webapp-config |
1640 |
complete -F _webapp_config webapp-config |
1703 |
} |
|
|
1704 |
|
1641 |
|
1705 |
have revdep-rebuild && { |
|
|
1706 |
_revdep_rebuild() { |
1642 |
_revdep_rebuild() { |
1707 |
local cur prev numwords opts |
1643 |
local cur prev numwords opts |
1708 |
local words i x |
1644 |
local words i x |
Lines 1715-1721
_revdep_rebuild() {
Link Here
|
1715 |
if [[ ${prev} == '>' || ${prev} == '<' ]] ; then |
1651 |
if [[ ${prev} == '>' || ${prev} == '<' ]] ; then |
1716 |
COMPREPLY=($(compgen -f -- ${cur})) |
1652 |
COMPREPLY=($(compgen -f -- ${cur})) |
1717 |
return 0 |
1653 |
return 0 |
1718 |
fi |
1654 |
fi |
1719 |
|
1655 |
|
1720 |
# find action |
1656 |
# find action |
1721 |
for ((i = 0; i < ${numwords}; i++ )); do |
1657 |
for ((i = 0; i < ${numwords}; i++ )); do |
Lines 1740-1746
_revdep_rebuild() {
Link Here
|
1740 |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) |
1676 |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) |
1741 |
fi |
1677 |
fi |
1742 |
return 0 |
1678 |
return 0 |
1743 |
fi |
1679 |
fi |
1744 |
if [[ ${action} == '--library' ]] || [[ ${action} == '-L' ]] ; then |
1680 |
if [[ ${action} == '--library' ]] || [[ ${action} == '-L' ]] ; then |
1745 |
if [[ "${cur}" == */* ]]; then |
1681 |
if [[ "${cur}" == */* ]]; then |
1746 |
COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -f -- "${cur}") ) |
1682 |
COMPREPLY=( $(builtin cd @GENTOO_PORTAGE_EPREFIX@/lib; compgen -f -- "${cur}") ) |
Lines 1749-1759
_revdep_rebuild() {
Link Here
|
1749 |
fi |
1685 |
fi |
1750 |
fi |
1686 |
fi |
1751 |
return 0 |
1687 |
return 0 |
1752 |
} |
1688 |
} && |
1753 |
complete -F _revdep_rebuild revdep-rebuild |
1689 |
complete -F _revdep_rebuild revdep-rebuild |
1754 |
} |
|
|
1755 |
|
1690 |
|
1756 |
have splat && { |
|
|
1757 |
_splat() { |
1691 |
_splat() { |
1758 |
local cur prev opts |
1692 |
local cur prev opts |
1759 |
COMPREPLY=() |
1693 |
COMPREPLY=() |
Lines 1776-1786
_splat() {
Link Here
|
1776 |
COMPREPLY=($(compgen -W "${COMPREPLY[@]} ${opts}" -- ${cur})) |
1710 |
COMPREPLY=($(compgen -W "${COMPREPLY[@]} ${opts}" -- ${cur})) |
1777 |
;; |
1711 |
;; |
1778 |
esac |
1712 |
esac |
1779 |
} |
1713 |
} && |
1780 |
complete -o filenames -F _splat splat |
1714 |
complete -o filenames -F _splat splat |
1781 |
} |
|
|
1782 |
|
1715 |
|
1783 |
have euse && { |
|
|
1784 |
_euse() { |
1716 |
_euse() { |
1785 |
local cur prev opts sopts use portdir |
1717 |
local cur prev opts sopts use portdir |
1786 |
COMPREPLY=() |
1718 |
COMPREPLY=() |
Lines 1830-1840
_euse() {
Link Here
|
1830 |
COMPREPLY=($(compgen -W "${use}" -- ${cur})) |
1762 |
COMPREPLY=($(compgen -W "${use}" -- ${cur})) |
1831 |
fi |
1763 |
fi |
1832 |
esac |
1764 |
esac |
1833 |
} |
1765 |
} && |
1834 |
complete -F _euse euse |
1766 |
complete -F _euse euse |
1835 |
} |
|
|
1836 |
|
1767 |
|
1837 |
have glsa-check && { |
|
|
1838 |
_glsa_check() { |
1768 |
_glsa_check() { |
1839 |
local cur opts |
1769 |
local cur opts |
1840 |
COMPREPLY=() |
1770 |
COMPREPLY=() |
Lines 1859-1869
_glsa_check() {
Link Here
|
1859 |
fi |
1789 |
fi |
1860 |
|
1790 |
|
1861 |
COMPREPLY=($(compgen -W "${opts} $(< ${ROOT}/tmp/gc.out)" -- ${cur})) |
1791 |
COMPREPLY=($(compgen -W "${opts} $(< ${ROOT}/tmp/gc.out)" -- ${cur})) |
1862 |
} |
1792 |
} && |
1863 |
complete -F _glsa_check glsa-check |
1793 |
complete -F _glsa_check glsa-check |
1864 |
} |
|
|
1865 |
|
1794 |
|
1866 |
have epm && { |
|
|
1867 |
_epm() { |
1795 |
_epm() { |
1868 |
local cur prev opts |
1796 |
local cur prev opts |
1869 |
COMPREPLY=() |
1797 |
COMPREPLY=() |
Lines 1901-1911
_epm() {
Link Here
|
1901 |
fi |
1829 |
fi |
1902 |
;; |
1830 |
;; |
1903 |
esac |
1831 |
esac |
1904 |
} |
1832 |
} && |
1905 |
complete -o filenames -F _epm epm |
1833 |
complete -o filenames -F _epm epm |
1906 |
} |
|
|
1907 |
|
1834 |
|
1908 |
have metagen && |
|
|
1909 |
_metagen() { |
1835 |
_metagen() { |
1910 |
local cur prev opts |
1836 |
local cur prev opts |
1911 |
COMPREPLY=() |
1837 |
COMPREPLY=() |
Lines 1927-1936
_metagen() {
Link Here
|
1927 |
|
1853 |
|
1928 |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) |
1854 |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) |
1929 |
return 0 |
1855 |
return 0 |
1930 |
} |
1856 |
} && |
1931 |
complete -F _metagen metagen |
1857 |
complete -F _metagen metagen |
1932 |
|
1858 |
|
1933 |
have rc-service && { |
|
|
1934 |
_rc_service() { |
1859 |
_rc_service() { |
1935 |
local cur prev numwords opts |
1860 |
local cur prev numwords opts |
1936 |
local words i x filename |
1861 |
local words i x filename |
Lines 1943-1949
_rc_service() {
Link Here
|
1943 |
if [[ ${prev} == '>' || ${prev} == '<' ]] ; then |
1868 |
if [[ ${prev} == '>' || ${prev} == '<' ]] ; then |
1944 |
COMPREPLY=($(compgen -f -- ${cur})) |
1869 |
COMPREPLY=($(compgen -f -- ${cur})) |
1945 |
return 0 |
1870 |
return 0 |
1946 |
fi |
1871 |
fi |
1947 |
|
1872 |
|
1948 |
# find action |
1873 |
# find action |
1949 |
for x in ${COMP_LINE} ; do |
1874 |
for x in ${COMP_LINE} ; do |
Lines 1961-1967
_rc_service() {
Link Here
|
1961 |
break |
1886 |
break |
1962 |
fi |
1887 |
fi |
1963 |
done |
1888 |
done |
1964 |
|
1889 |
|
1965 |
for ((i = 1; i < ${numwords}; i++ )); do |
1890 |
for ((i = 1; i < ${numwords}; i++ )); do |
1966 |
if [[ ! ${COMP_WORDS[$i]} == -* ]]; then |
1891 |
if [[ ! ${COMP_WORDS[$i]} == -* ]]; then |
1967 |
break |
1892 |
break |
Lines 1972-1978
_rc_service() {
Link Here
|
1972 |
if [[ ${COMP_CWORD} -eq 3 ]]; then |
1897 |
if [[ ${COMP_CWORD} -eq 3 ]]; then |
1973 |
return 1 |
1898 |
return 1 |
1974 |
fi |
1899 |
fi |
1975 |
|
1900 |
|
1976 |
# check if an option was typed |
1901 |
# check if an option was typed |
1977 |
if [[ ${cur} == -* ]]; then |
1902 |
if [[ ${cur} == -* ]]; then |
1978 |
if [[ ${cur} == --* ]]; then |
1903 |
if [[ ${cur} == --* ]]; then |
Lines 1985-1991
_rc_service() {
Link Here
|
1985 |
return 0 |
1910 |
return 0 |
1986 |
fi |
1911 |
fi |
1987 |
|
1912 |
|
1988 |
|
1913 |
|
1989 |
# NOTE: This slows things down! |
1914 |
# NOTE: This slows things down! |
1990 |
# (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>) |
1915 |
# (Adapted from bash_completion by Ian Macdonald <ian@caliban.org>) |
1991 |
# This removes any options from the list of completions that have |
1916 |
# This removes any options from the list of completions that have |
Lines 2029-2037
_rc_service() {
Link Here
|
2029 |
done)) |
1954 |
done)) |
2030 |
return 0 |
1955 |
return 0 |
2031 |
fi |
1956 |
fi |
2032 |
|
1957 |
|
2033 |
return 0 |
1958 |
return 0 |
2034 |
} |
1959 |
} && |
2035 |
complete -F _rc_service rc-service |
1960 |
complete -F _rc_service rc-service |
2036 |
} |
1961 |
|
2037 |
# vim: ft=sh:et:ts=4:sw=4:tw=80 |
1962 |
# vim: ft=sh:et:ts=4:sw=4:tw=80 |