1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
# (C) 2016 magicant
# Completion script for the "tree" command.
# Supports tree 1.7.0.
function completion/tree {
typeset OPTIONS ARGOPT PREFIX
OPTIONS=( #>#
"A; enable ANSI line graphics hack for indentation"
"a; print all files (including dot-starting filenames)"
"C; print filenames in color"
"c; print or sort by last status change time"
"--charset:; specify a character set to print in"
"D; prepend last modified time to filenames"
"d; print directories only"
"--device; prepend device number to filenames"
"--dirsfirst; list directories before other files"
"--du; print the total sizes of directories"
"F; append symbols indicating file type"
"f; print pathnames instead of filenames"
"--filelimit:; don't descend directories with more than the specified number of files"
"g; prepend group name to filenames"
"H:; print in HTML with the specified base URL"
"h; print size using K, M, etc. for 1024^n"
"I:; specify a pattern to exclude from printed filenames"
"i; don't indent filenames"
"--ignore-case; make pattern matching case-insensitive (with -I/-P)"
"--inodes; prepend inode number to filenames"
"J; print in JSON"
"L:; specify directory depth to limit printing"
"l; follow all symbolic links"
"--matchdirs; apply patterns to directory names as well as file names"
"N; print unprintable characters as is"
"n; disable colored output"
"--nolinks; disable hyperlinks in HTML output"
"--noreport; don't print count of directories and files"
"o:; specify a file to print to"
"P:; specify a pattern to filter printed filenames"
"p; prepend permissions to filenames"
"--prune; exclude empty directories"
"Q; double-quote filenames"
"q; print unprintable characters as ?"
"r; sort in reverse order"
"S; like --charset=IBM437"
"s; prepend file size to filenames"
"--si; print size using k, M, etc. for 1000^n"
"--sort::; specify a sort key"
"T:; specify a title for HTML output"
"t; sort by last modified time"
"--timefmt:; specify a format for printing date"
"U; don't sort"
"u; prepend user name to filenames"
"v; sort filenames regarding as version numbers"
"X; print in XML"
"x; don't search different file systems"
"--help"
"--version"
) #<#
command -f completion//parseoptions -en
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
([HL]|--filelimit)
;;
(--charset)
# TODO --charset
;;
(--sort) #>>#
complete -P "$PREFIX" name size
complete -P "$PREFIX" -D "last status change time" ctime
complete -P "$PREFIX" -D "last modified time" mtime
complete -P "$PREFIX" -D "name as version number" version
;; #<<#
(--timefmt)
if command -vf completion//completestrftime >/dev/null 2>&1 ||
. -AL completion/date; then
command -f completion//completestrftime
fi
;;
('')
complete -P "$PREFIX" -S / -T -d
;;
(*)
complete -P "$PREFIX" -f
;;
esac
}
# vim: set ft=sh ts=8 sts=8 sw=8 et:
|