#compdef stat autoload -U is-at-least _stat() { 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[@]}" : \ '-c+[use the specified FORMAT instead of the default; output a newline after each use of FORMAT]:FORMAT:_default' \ '--format=[use the specified FORMAT instead of the default; output a newline after each use of FORMAT]:FORMAT:_default' \ '--printf=[like --format, but interpret backslash escapes, and do not output a mandatory trailing newline; if you want a newline, include \\n in FORMAT]:FORMAT:_default' \ '-L[follow links]' \ '--dereference[follow links]' \ '-f[display file system status instead of file status]' \ '--file-system[display file system status instead of file status]' \ '-t[print the information in terse form]' \ '--terse[print the information in terse form]' \ '-h[Print help]' \ '--help[Print help]' \ '-V[Print version]' \ '--version[Print version]' \ '::files:_files' \ && ret=0 } (( $+functions[_stat_commands] )) || _stat_commands() { local commands; commands=() _describe -t commands 'stat commands' commands "$@" } if [ "$funcstack[1]" = "_stat" ]; then _stat "$@" else compdef _stat stat fi