[Bash-completion-commits] ./current r1280: completion for quota-tools
Guillaume Rousse
guillomovitch at zarb.org
Mon Jan 19 21:11:47 UTC 2009
------------------------------------------------------------
revno: 1280
committer: Guillaume Rousse <guillomovitch at zarb.org>
branch nick: current
timestamp: Mon 2009-01-19 22:11:47 +0100
message:
completion for quota-tools
added:
to_review/quota-tools
-------------- next part --------------
=== added file 'to_review/quota-tools'
--- a/to_review/quota-tools 1970-01-01 00:00:00 +0000
+++ b/to_review/quota-tools 2009-01-19 21:11:47 +0000
@@ -0,0 +1,211 @@
+# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
+# ex: ts=8 sw=8 noet filetype=sh
+#
+# bash completion for quota-tools
+
+have quota && {
+_user_or_group()
+{
+ local i
+
+ # complete on groups if -g was given
+ for (( i=1; i < COMP_CWORD; i++ )); do
+ if [[ "${COMP_WORDS[i]}" == -g ]]; then
+ COMPREPLY=( $( compgen -g -- $cur ) )
+ return 0
+ fi
+ done
+
+ # otherwise complete on users
+ COMPREPLY=( $( compgen -u -- $cur ) )
+}
+
+_quota_formats()
+{
+ COMPREPLY=( $( compgen -W 'vfsold vfsv0 rpc xfs' -- $cur ) )
+}
+
+_filesystems()
+{
+ COMPREPLY=( $( compgen -W '$(awk '!/^none/ {print $1}' /etc/mtab)' \
+ -- $cur ) )
+}
+
+
+_quota()
+{
+ local cur prev
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case $prev in
+ -F)
+ _quota_formats
+ return 0
+ ;;
+ esac
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-F -g -u -v -s -i -l -q -Q' -- $cur ) )
+ else
+ _user_or_group
+ fi
+}
+complete -F _quota quota
+
+_setquota()
+{
+ local cur prev
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case $prev in
+ -F)
+ _quota_formats
+ return 0
+ ;;
+ esac
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-r -F -g -u -p -b -t -T -a' -- $cur ) )
+ else
+ _count_args
+
+ case $args in
+ 1)
+ _user_or_group
+ ;;
+ 2)
+ _filesystems
+ ;;
+ esac
+
+ fi
+}
+complete -F _setquota setquota
+
+_edquota()
+{
+ local cur prev
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case $prev in
+ -F)
+ _quota_formats
+ return 0
+ ;;
+ -f)
+ _filesystems
+ return 0
+ ;;
+ esac
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-r -g -u -p -F -f -t -T' -- $cur ) )
+ else
+ _user_or_group
+ fi
+}
+complete -F _edquota edquota
+
+_quotacheck()
+{
+ local cur prev
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case $prev in
+ -F)
+ _quota_formats
+ return 0
+ ;;
+ esac
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-g -u -b -c -f -i -n -v -d -M -m -R \
+ -F -a' -- $cur ) )
+ else
+ _filesystems
+ fi
+}
+complete -F _quotacheck quotacheck
+
+_repquota()
+{
+ local cur prev
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case $prev in
+ -F)
+ _quota_formats
+ return 0
+ ;;
+ esac
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-v -s -i -u -g -c -C -t -n -F' -- \
+ $cur ) )
+ else
+ _filesystems
+ fi
+}
+complete -F _repquota repquota
+
+_quotaon()
+{
+ local cur prev
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case $prev in
+ -F)
+ _quota_formats
+ return 0
+ ;;
+ esac
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-a -v -u -g -f -p -F' -- $cur ) )
+ else
+ _filesystems
+ fi
+}
+complete -F _quotaon quotaon
+
+_quotaoff()
+{
+ local cur prev
+
+ COMPREPLY=()
+ cur=`_get_cword`
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case $prev in
+ -F)
+ _quota_formats
+ return 0
+ ;;
+ esac
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-a -v -u -g -p -x' -- $cur ) )
+ else
+ _filesystems
+ fi
+}
+complete -F _quotaoff quotaoff
+}
More information about the Bash-completion-commits
mailing list