home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / quota-tools < prev    next >
Encoding:
Text File  |  2010-11-16  |  5.4 KB  |  258 lines

  1. # bash completion for quota-tools
  2.  
  3. have quota && {
  4. _user_or_group()
  5. {
  6.     local i
  7.  
  8.     # complete on groups if -g was given
  9.     for (( i=1; i < COMP_CWORD; i++ )); do
  10.         if [[ "${COMP_WORDS[i]}" == -g ]]; then
  11.             COMPREPLY=( $( compgen -g -- "$cur" ) )
  12.             return 0
  13.         fi
  14.     done
  15.  
  16.     # otherwise complete on users
  17.     COMPREPLY=( $( compgen -u -- "$cur" ) )
  18. }
  19.  
  20. _quota_formats()
  21. {
  22.     COMPREPLY=( $( compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur" ) )
  23. }
  24.  
  25. _filesystems()
  26. {
  27.     #  Only list filesystems starting with "/", otherwise we also get
  28.     #+ "binfmt_misc", "proc", "tmpfs", ...
  29.     COMPREPLY=( $( compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \
  30.         -- "$cur" ) )
  31. }
  32.  
  33. _quota()
  34. {
  35.     local cur prev split=false
  36.  
  37.     COMPREPLY=()
  38.     _get_comp_words_by_ref cur prev
  39.  
  40.     _split_longopt && split=true
  41.  
  42.     case $prev in
  43.         -F|--format)
  44.             _quota_formats
  45.             return 0
  46.             ;;
  47.     esac
  48.  
  49.     $split && return 0
  50.  
  51.     if [[ "$cur" == -* ]]; then
  52.         COMPREPLY=( $( compgen -W '-F --format -g --group -u --user -v \
  53.             --verbose -s --human-readable -p --raw-grace -i --no-autofs -l \
  54.             --local-only -A --all-nfs -m --no-mixed-pathnames -q --quiet -Q \
  55.             --quiet-refuse -w --no-wrap' -- "$cur" ) )
  56.     else
  57.         _user_or_group
  58.     fi
  59. }
  60. complete -F _quota -o default quota
  61.  
  62. _setquota()
  63. {
  64.     local cur prev split=false
  65.  
  66.     COMPREPLY=()
  67.     _get_comp_words_by_ref cur prev
  68.  
  69.     _split_longopt && split=true
  70.  
  71.     case $prev in
  72.         -F|--format)
  73.             _quota_formats
  74.             return 0
  75.             ;;
  76.     esac
  77.  
  78.     $split && return 0
  79.  
  80.     if [[ "$cur" == -* ]]; then
  81.         COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
  82.             -F --format -g --group -u --user -p --prototype -b --batch \
  83.             -c --continue-batch -t --edit-period -T --edit-times -a --all' \
  84.             -- "$cur" ) )
  85.     else
  86.         _count_args
  87.  
  88.         case $args in
  89.             1)
  90.                 _user_or_group
  91.                 ;;
  92.             2)
  93.                 _filesystems
  94.                 ;;
  95.         esac
  96.  
  97.     fi
  98. }
  99. complete -F _setquota -o default setquota
  100.  
  101. _edquota()
  102. {
  103.     local cur prev split=false
  104.  
  105.     COMPREPLY=()
  106.     _get_comp_words_by_ref cur prev
  107.  
  108.     _split_longopt && split=true
  109.  
  110.     case $prev in
  111.         -F|--format)
  112.             _quota_formats
  113.             return 0
  114.             ;;
  115.         -f|--filesystem)
  116.             _filesystems
  117.             return 0
  118.             ;;
  119.     esac
  120.  
  121.     $split && return 0
  122.  
  123.     if [[ "$cur" == -* ]]; then
  124.         COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
  125.             -g --group -u --user -p --prototype -F --format -f --filesystem \
  126.             -t --edit-period -T --edit-times' -- "$cur" ) )
  127.     else
  128.         _user_or_group
  129.     fi
  130. }
  131. complete -F _edquota -o default edquota
  132.  
  133. _quotacheck()
  134. {
  135.     local cur prev split=false
  136.  
  137.     COMPREPLY=()
  138.     _get_comp_words_by_ref cur prev
  139.  
  140.     _split_longopt && split=true
  141.  
  142.     case $prev in
  143.         -F|--format)
  144.             _quota_formats
  145.             return 0
  146.             ;;
  147.     esac
  148.  
  149.     $split && return 0
  150.  
  151.     if [[ "$cur" == -* ]]; then
  152.         COMPREPLY=( $( compgen -W '-b --backup -v --verbose -d --debug \
  153.             -g --group -u --user -c --create-files -f --force -i \
  154.             --interactive -n --use-first-dquot -M --try-remount -m \
  155.             --no-remount -R --exclude-root -F --format -a --all' -- "$cur" ) )
  156.     else
  157.         _filesystems
  158.     fi
  159. }
  160. complete -F _quotacheck -o default quotacheck
  161.  
  162. _repquota()
  163. {
  164.     local cur prev split=false
  165.  
  166.     COMPREPLY=()
  167.     _get_comp_words_by_ref cur prev
  168.  
  169.     _split_longopt && split=true
  170.  
  171.     case $prev in
  172.         -F|--format)
  173.             _quota_formats
  174.             return 0
  175.             ;;
  176.     esac
  177.  
  178.     $split && return 0
  179.  
  180.     if [[ "$cur" == -* ]]; then
  181.         COMPREPLY=( $( compgen -W '-a --all -v --verbose -s --human-readable \
  182.             -c --batch-translation -C --no-batch-translation -t \
  183.             --truncate-names -n --no-names -p --raw-grace -i --no-autofs \
  184.             -u --user -g --group -F --format' -- "$cur" ) )
  185.     else
  186.         _filesystems
  187.     fi
  188. }
  189. complete -F _repquota -o default repquota
  190.  
  191. _quotaon()
  192. {
  193.     local cur prev split=false
  194.  
  195.     COMPREPLY=()
  196.     _get_comp_words_by_ref cur prev
  197.  
  198.     _split_longopt && split=true
  199.  
  200.     case $prev in
  201.         -F|--format)
  202.             _quota_formats
  203.             return 0
  204.             ;;
  205.     esac
  206.  
  207.     $split && return 0
  208.  
  209.     if [[ "$cur" == -* ]]; then
  210.         COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
  211.             -g --group -f --off -p --print-state -F --format' -- "$cur" ) )
  212.     else
  213.         _filesystems
  214.     fi
  215. }
  216. complete -F _quotaon -o default quotaon
  217.  
  218. _quotaoff()
  219. {
  220.     local cur prev split=false
  221.  
  222.     COMPREPLY=()
  223.     _get_comp_words_by_ref cur prev
  224.  
  225.     _split_longopt && split=true
  226.  
  227.     case $prev in
  228.         -F|--format)
  229.             _quota_formats
  230.             return 0
  231.             ;;
  232.         -x|--xfs-command)
  233.             COMPREPLY=( $( compgen -W 'delete enforce' -- "$cur" ) )
  234.             return 0
  235.             ;;
  236.     esac
  237.  
  238.     $split && return 0
  239.  
  240.     if [[ "$cur" == -* ]]; then
  241.         COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
  242.             -g --group -p --print-state -x --xfs-command -F --format' \
  243.             -- "$cur" ) )
  244.     else
  245.         _filesystems
  246.     fi
  247. }
  248. complete -F _quotaoff -o default quotaoff
  249. }
  250.  
  251. # Local variables:
  252. # mode: shell-script
  253. # sh-basic-offset: 4
  254. # sh-indent-comment: t
  255. # indent-tabs-mode: nil
  256. # End:
  257. # ex: ts=4 sw=4 et filetype=sh
  258.