#compdef df

autoload -U is-at-least

_df() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-B+[scale sizes by SIZE before printing them; e.g. '\''-BM'\'' prints sizes in units of 1,048,576 bytes]:SIZE:_default' \
'--block-size=[scale sizes by SIZE before printing them; e.g. '\''-BM'\'' prints sizes in units of 1,048,576 bytes]:SIZE:_default' \
'(-i --inodes -P --portability -T --print-type)*--output=[use output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.]::FIELD_LIST:(source fstype itotal iused iavail ipcent size used avail pcent file target)' \
'*-t+[limit listing to file systems of type TYPE]:TYPE:_default' \
'*--type=[limit listing to file systems of type TYPE]:TYPE:_default' \
'*-x+[limit listing to file systems not of type TYPE]:TYPE:_default' \
'*--exclude-type=[limit listing to file systems not of type TYPE]:TYPE:_default' \
'--help[Print help information.]' \
'-a[include dummy file systems]' \
'--all[include dummy file systems]' \
'--total[produce a grand total]' \
'-h[print sizes in human readable format (e.g., 1K 234M 2G)]' \
'--human-readable[print sizes in human readable format (e.g., 1K 234M 2G)]' \
'-H[likewise, but use powers of 1000 not 1024]' \
'--si[likewise, but use powers of 1000 not 1024]' \
'-i[list inode information instead of block usage]' \
'--inodes[list inode information instead of block usage]' \
'-k[like --block-size=1K]' \
'-l[limit listing to local file systems]' \
'--local[limit listing to local file systems]' \
'--no-sync[do not invoke sync before getting usage info (default)]' \
'-P[use the POSIX output format]' \
'--portability[use the POSIX output format]' \
'--sync[invoke sync before getting usage info (non-windows only)]' \
'-T[print file system type]' \
'--print-type[print file system type]' \
'-V[Print version]' \
'--version[Print version]' \
'::paths:_files' \
&& ret=0
}

(( $+functions[_df_commands] )) ||
_df_commands() {
    local commands; commands=()
    _describe -t commands 'df commands' commands "$@"
}

if [ "$funcstack[1]" = "_df" ]; then
    _df "$@"
else
    compdef _df df
fi
