vbuilder-bash-completion.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 --login --bootstrap-dir --unionfs-dir --cache-dir --built-rpms-dir --debug"
  21. actions="clean build build-rpm install-rpm remove-rpm"
  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. local running="VineSeed 6.0 5.2 4.2"
  28. COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
  29. ;;
  30. --arch)
  31. local running="i386 ppc x86_64 arm"
  32. COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
  33. ;;
  34. --category)
  35. local running="main proposed-updates,main plus,main nonfree,plus,main test,nonfree,plus,main test,plus,main test,main"
  36. COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
  37. ;;
  38. --target)
  39. local running="$(cat /usr/lib/rpm/rpmrc | grep arch_canon: | sed -e "s/arch_canon:[[:blank:]]*\(.*\):.*/\1/") noarch"
  40. COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
  41. ;;
  42. --bootstrap-dir|--unionfs-dir|--cache-dir|--built-rpms-dir)
  43. if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
  44. _filedir ''
  45. fi
  46. ;;
  47. build-rpm)
  48. if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
  49. _filedir 'src.rpm'
  50. fi
  51. ;;
  52. install-rpm|remove-rpm)
  53. if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
  54. _filedir 'rpm'
  55. fi
  56. ;;
  57. *)
  58. COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
  59. #return 0
  60. ;;
  61. esac
  62. if [[ "${cur}" == -* ]] ; then
  63. COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
  64. #return 0
  65. fi
  66. }
  67. complete -o filenames -o nospace -F _vbuilder vbuilder
  68. ### end of file