[484] | 1 | [ -z "$BASH_VERSION" ] && return |
---|
| 2 | |
---|
| 3 | _filedir() |
---|
| 4 | { |
---|
| 5 | local IFS=$'\t\n' xspec #glob |
---|
| 6 | |
---|
| 7 | #glob=$(set +o|grep noglob) # save glob setting. |
---|
| 8 | #set -f # disable pathname expansion (globbing) |
---|
| 9 | |
---|
| 10 | xspec=${1:+"!*.$1"} # set only if glob passed in as $1 |
---|
| 11 | COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -f -X "$xspec" -- "$cur" ) \ |
---|
| 12 | $( compgen -d -- "$cur" ) ) |
---|
| 13 | #eval "$glob" # restore glob setting. |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | _vbuilder() |
---|
| 17 | { |
---|
| 18 | local opts cur prev first |
---|
| 19 | COMPREPLY=() |
---|
| 20 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 21 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 22 | first="${COMP_WORDS[1]}" |
---|
| 23 | |
---|
| 24 | ## The basic options we'll complete. |
---|
[795] | 25 | options="--version --arch --category --dist-upgrade --unionfs --target --with-compat32" |
---|
[725] | 26 | actions="clean build build-rpm install-rpm remove-rpm show-info" |
---|
[484] | 27 | opts="$options $actions" |
---|
| 28 | |
---|
| 29 | _arch=$(rpm --eval %_arch) |
---|
| 30 | |
---|
| 31 | in_options=0 |
---|
| 32 | |
---|
| 33 | ## Complete the arguments to some of the basic commands. |
---|
| 34 | case "${prev}" in |
---|
| 35 | --version) |
---|
| 36 | if [ "$_arch" = "x86_64" ]; then |
---|
[690] | 37 | local running="VineSeed VineSeed_i386 5.1 5.1_i386 4.2_i386" |
---|
[484] | 38 | else |
---|
[690] | 39 | local running="VineSeed 5.1 4.2" |
---|
[484] | 40 | fi |
---|
| 41 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 42 | ;; |
---|
| 43 | |
---|
| 44 | --arch) |
---|
| 45 | local running="i386 ppc x86_64" |
---|
| 46 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 47 | ;; |
---|
| 48 | |
---|
[795] | 49 | --category) |
---|
| 50 | local running="main main,proposed-updates main,plus main,plus,nonfree" |
---|
| 51 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 52 | ;; |
---|
| 53 | |
---|
[484] | 54 | --target) |
---|
| 55 | local running="$(cat /usr/lib/rpm/rpmrc | grep arch_canon: | sed -e "s/arch_canon:[[:blank:]]*\(.*\):.*/\1/")" |
---|
| 56 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 57 | ;; |
---|
| 58 | |
---|
[679] | 59 | --build-rpm|build-rpm) |
---|
[484] | 60 | if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then |
---|
| 61 | _filedir 'src.rpm' |
---|
| 62 | fi |
---|
| 63 | ;; |
---|
| 64 | |
---|
[679] | 65 | --install-rpm|install-rpm|--remove-rpm|remove-rpm) |
---|
[484] | 66 | if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then |
---|
| 67 | _filedir 'rpm' |
---|
| 68 | fi |
---|
| 69 | ;; |
---|
| 70 | |
---|
| 71 | *) |
---|
| 72 | COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) |
---|
| 73 | #return 0 |
---|
| 74 | ;; |
---|
| 75 | esac |
---|
| 76 | |
---|
| 77 | if [[ "${cur}" == -* ]] ; then |
---|
| 78 | COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) |
---|
| 79 | #return 0 |
---|
| 80 | fi |
---|
| 81 | |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | complete -o filenames -o nospace -F _vbuilder vbuilder |
---|
| 85 | |
---|
| 86 | ### end of file |
---|