#compdef tree

# tree has its own weird option-parsing method that requires arguments to short
# options to appear in the next word... except for -L (as of 2.2.1)
_arguments -s -S \
  '-a[show all files, including hidden ones]' \
  '-d[list directories only]' \
  '-l[follow symlinks that point to directories]' \
  '-f[print full path prefix for each file]' \
  '-x[stay on current filesystem]' \
  '-L+[specify max tree depth to descend]: :_numbers -l1 depth' \
  '-R[recursively cross down the tree and execute tree again]' \
  '-P[only list files matching specified pattern]:pattern:_files' \
  "-I[don't list files matching specified pattern]:pattern:_files" \
  '--gitignore[respect .gitignore files for filtering]' \
  '*--gitfile=[use specified file as gitignore file]:gitignore file:_files' \
  '--ignore-case[ignore case when pattern matching]' \
  '--matchdirs[include directory names in -P pattern matching]' \
  '--metafirst[print file meta-data at beginning of line]' \
  '--info[print file comments found in .info files]' \
  '*--infofile=[use specified file as info file]:info file:_files' \
  '--noreport[omit file and directory report at end]' \
  '--charset=[specify character set for HTML and line drawing]:charset' \
  "--filelimit=[don't descend directories with more than specified number of entries]: :_numbers entries" \
  '--timefmt=[use specified time format]: :_date_formats' \
  '-o[output to specified file]: :_files' \
  '--du[print directory sizes]' \
  '--prune[exclude empty directories from the output]' \
  '(-N)-q[print non-printable characters as question mark, not caret]' \
  '(-q)-N[print non-printable characters as is, not as caret]' \
  '-Q[quote filenames with double quotes]' \
  '-p[print file type and permissions, like ls -l]' \
  '-u[print file owner]' \
  '-g[print file group]' \
  '(-h --si)-s[print size of each file in bytes]' \
  '(-s --si)-h[print human readable file size]' \
  '(-s -h)--si[print human readable file size in SI units (powers of 1000)]' \
  '-D[print last modification date or change time (with -c)]' \
  '-F[append descriptive character to end, like ls -F]' \
  '--inodes[print inode numbers]' \
  '--device[print device number to which file or directory belongs]' \
  '(--sort -t -c -U)-v[sort output as version]' \
  '(-v --sort -c -U)-t[sort output by modification time]' \
  '(-v --sort -t -U)-c[sort output by change time]' \
  '(-v --sort -t -c -r --dirsfirst)-U[leave files unsorted]' \
  '(-U)-r[sort in reversed order]' \
  '(-v -t -c -U)--sort=[sort in specified order]:order:(name version size mtime ctime none)' \
  '(-U --filesfirst)--dirsfirst[list directories before files]' \
  '(-U --dirsfirst)--filesfirst[list files before directories]' \
  "-i[don't print indentation lines]" \
  '(-S -H -J -X)-A[use ANSI line graphics hack when printing indentation lines]' \
  '(-A)-S[equivalent to --charset=IBM437]' \
  '(-C)-n[turn colorization off always]' \
  '(-n)-C[turn colorization on always]' \
  '(-A -J -H -T --nolinks)-X[turn on XML output]' \
  '(-A -X -H -T --nolinks)-J[turn on JSON output]' \
  '(-A -J -X)-H[turn on HTML output]:base HREF' \
  '(-A -J -X)--hintro=[use specified file as HTML intro]:HTML intro file:_files' \
  '(-A -J -X)--houtro=[use specified file as HTML outro]:HTML outro file:_files' \
  '(-A -J -X)-T[specify title for HTML output]:title' \
  '(-A -J -X --hyperlink)--nolinks[turn off hyperlinks in HTML output]' \
  '(-H -J -X --nolinks)--hyperlink[turn on OSC 8 hyperlinks]' \
  '(-H -J -X --nolinks)--scheme=[specify schema used for OSC 8 hyperlinks]:schema [file\://]' \
  '(-H -J -X --nolinks)--authority=[specify authority (host name) used for OSC 8 hyperlinks]: :_hosts' \
  '(--fromtabfile)--fromfile[read paths from specified files]:paths file:_files' \
  '(--fromfile)--fromtabfile[read tab-indented paths from specified files]:paths file:_files' \
  '--fflinks[process symbolic link information with in files (with --from*file)]' \
  '--opt-toggle[turn on option toggling]' \
  '(- :)--version[display version information]' \
  '(- :)--help[display help information]' \
  '*: :_directories'
