251 lines
5.5 KiB
Plaintext
Raw Normal View History

2009-02-05 10:53:04 +01:00
# bash completion for quota-tools
have quota || return
2009-02-05 10:53:04 +01:00
_user_or_group()
{
2009-10-04 19:42:50 +02:00
local i
# complete on groups if -g was given
for (( i=1; i < cword; i++ )); do
if [[ "${words[i]}" == -g ]]; then
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -g -- "$cur" ) )
return 0
fi
done
# otherwise complete on users
COMPREPLY=( $( compgen -u -- "$cur" ) )
2009-02-05 10:53:04 +01:00
}
_quota_formats()
{
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur" ) )
2009-02-05 10:53:04 +01:00
}
_filesystems()
{
2009-10-04 19:42:50 +02:00
# Only list filesystems starting with "/", otherwise we also get
#+ "binfmt_misc", "proc", "tmpfs", ...
COMPREPLY=( $( compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \
-- "$cur" ) )
2009-02-05 10:53:04 +01:00
}
_quota()
{
local cur prev words cword
_init_completion -n = || return
2009-10-04 19:42:50 +02:00
local split=false
2009-10-04 19:42:50 +02:00
_split_longopt && split=true
case $prev in
-F|--format)
_quota_formats
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-F --format -g --group -u --user -v \
--verbose -s --human-readable -p --raw-grace -i --no-autofs -l \
--local-only -A --all-nfs -m --no-mixed-pathnames -q --quiet -Q \
--quiet-refuse -w --no-wrap' -- "$cur" ) )
else
_user_or_group
fi
2011-04-04 22:14:39 +03:00
} &&
complete -F _quota -o default quota
2009-02-05 10:53:04 +01:00
_setquota()
{
local cur prev words cword
_init_completion -n = || return
2009-10-04 19:42:50 +02:00
local split=false
2009-10-04 19:42:50 +02:00
_split_longopt && split=true
case $prev in
-F|--format)
_quota_formats
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
-F --format -g --group -u --user -p --prototype -b --batch \
-c --continue-batch -t --edit-period -T --edit-times -a --all' \
-- "$cur" ) )
else
_count_args
case $args in
1)
_user_or_group
;;
2)
_filesystems
;;
esac
fi
2011-04-04 22:14:39 +03:00
} &&
complete -F _setquota -o default setquota
2009-02-05 10:53:04 +01:00
_edquota()
{
local cur prev words cword
_init_completion -n = || return
2009-10-04 19:42:50 +02:00
local split=false
2009-10-04 19:42:50 +02:00
_split_longopt && split=true
case $prev in
-F|--format)
_quota_formats
return 0
;;
-f|--filesystem)
2009-10-04 19:42:50 +02:00
_filesystems
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-r --remote -m --no-mixed-pathnames \
-g --group -u --user -p --prototype -F --format -f --filesystem \
-t --edit-period -T --edit-times' -- "$cur" ) )
else
_user_or_group
fi
2011-04-04 22:14:39 +03:00
} &&
complete -F _edquota -o default edquota
2009-02-05 10:53:04 +01:00
_quotacheck()
{
local cur prev words cword
_init_completion -n = || return
2009-10-04 19:42:50 +02:00
local split=false
2009-10-04 19:42:50 +02:00
_split_longopt && split=true
case $prev in
-F|--format)
_quota_formats
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b --backup -v --verbose -d --debug \
-g --group -u --user -c --create-files -f --force -i \
--interactive -n --use-first-dquot -M --try-remount -m \
--no-remount -R --exclude-root -F --format -a --all' -- "$cur" ) )
else
_filesystems
fi
2011-04-04 22:14:39 +03:00
} &&
complete -F _quotacheck -o default quotacheck
2009-02-05 10:53:04 +01:00
_repquota()
{
local cur prev words cword
_init_completion -n = || return
2009-10-04 19:42:50 +02:00
local split=false
2009-10-04 19:42:50 +02:00
_split_longopt && split=true
case $prev in
-F|--format)
_quota_formats
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all -v --verbose -s --human-readable \
-c --batch-translation -C --no-batch-translation -t \
--truncate-names -n --no-names -p --raw-grace -i --no-autofs \
-u --user -g --group -F --format' -- "$cur" ) )
else
_filesystems
fi
2011-04-04 22:14:39 +03:00
} &&
complete -F _repquota -o default repquota
2009-02-05 10:53:04 +01:00
_quotaon()
{
local cur prev words cword
_init_completion -n = || return
2009-02-05 10:53:04 +01:00
local split=false
2009-10-04 19:42:50 +02:00
_split_longopt && split=true
2009-10-04 19:42:50 +02:00
case $prev in
-F|--format)
_quota_formats
return 0
;;
esac
2009-02-05 10:53:04 +01:00
2009-10-04 19:42:50 +02:00
$split && return 0
2009-02-05 10:53:04 +01:00
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
-g --group -f --off -p --print-state -F --format' -- "$cur" ) )
else
_filesystems
fi
2011-04-04 22:14:39 +03:00
} &&
complete -F _quotaon -o default quotaon
2009-02-05 10:53:04 +01:00
_quotaoff()
{
local cur prev words cword
_init_completion -n = || return
2009-10-04 19:42:50 +02:00
local split=false
2009-10-04 19:42:50 +02:00
_split_longopt && split=true
case $prev in
-F|--format)
_quota_formats
return 0
;;
-x|--xfs-command)
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W 'delete enforce' -- "$cur" ) )
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all -v --verbose -u --user \
-g --group -p --print-state -x --xfs-command -F --format' \
-- "$cur" ) )
else
_filesystems
fi
2011-04-04 22:14:39 +03:00
} &&
complete -F _quotaoff -o default quotaoff
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh