vbuilder-bash-completion.sh 2.4 KB

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