1#compdef ls gls 2 3local arguments is_gnu datef 4 5if ! _pick_variant gnu=gnu unix --help; then 6 arguments=( 7 '(-A)-a[list entries starting with .]' 8 '(-a)-A[list all except . and ..]' 9 '-d[list directory entries instead of contents]' 10 '-L[list referenced file for sym link]' 11 '-R[list subdirectories recursively]' 12 13 '(-k)-h[print sizes in human readable form]' 14 '(-h)-k[print sizes in kilobytes]' 15 16 '-i[print file inode numbers]' 17 '(-l -g -1 -C -m -x)-l[long listing]' 18 '(-l -g -C -m -x)-1[single column output]' 19 '(-l -g -1 -m -x)-C[list entries in columns sorted vertically]' 20 '(-l -g -1 -C -x)-m[comma separated]' 21 '(-l -g -1 -C -m)-x[sort horizontally]' 22 23 '-s[display size of each file in blocks]' 24 25 '(-u)-c[status change time]' 26 '(-c)-u[access time]' 27 28 '-r[reverse sort order]' 29 30 '(-t)-S[sort by size]' 31 '(-S)-t[sort by modification time]' 32 33 '(-p)-F[append file type indicators]' 34 '(-F)-p[append file type indicators for directory]' 35 36 '-n[numeric uid, gid]' 37 38 '(-B -b -w -q)-q[hide control chars]' 39 40 '*: :_files' 41 ) 42 if [[ "$OSTYPE" = (netbsd*|dragonfly*|freebsd*|openbsd*|darwin*) ]]; then 43 arguments+=( 44 '-T[show complete time information]' 45 '(-a -A -r -S -t)-f[output is not sorted]' 46 ) 47 fi 48 if [[ $OSTYPE = (netbsd*|dragonfly*|freebsd*|openbsd*) ]]; then 49 arguments+=( '-o[display file flags]' ) 50 fi 51 if [[ $OSTYPE = (netbsd*|dragonfly*|freebsd*|darwin*) ]]; then 52 arguments+=( 53 '(-B -b -w -q)-B[print octal escapes for control characters]' 54 '(-B -b -w -q)-b[as -B, but use C escape codes whenever possible]' 55 '(-B -b -w -q)-w[print raw characters]' 56 '-W[display whiteouts when scanning directories]' 57 ) 58 fi 59 if [[ $OSTYPE = (netbsd*|openbsd*|darwin*|solaris*) ]]; then 60 arguments+=( 61 '(-l -1 -C -m -x)-g[long listing but without owner information]' 62 ) 63 fi 64 if [[ $OSTYPE = netbsd* ]]; then 65 arguments+=( 66 '-M[output file sizes in comma-separated form]' 67 '-O[output only leaf (non-directory) files]' 68 '-P[print full pathname for each file]' 69 "-X[don't cross mount points when recursing]" 70 ) 71 fi 72 if [[ $OSTYPE = (dragonfly*|freebsd*|openbsd*|darwin*) ]]; then 73 arguments+=( '-H[follow symlinks on the command line]' ) 74 fi 75 if [[ $OSTYPE = (dragonfly*|freebsd*|darwin*) ]]; then 76 arguments+=( 77 '-G[enable colorized output]' 78 '-P[do not follow symlinks]' 79 ) 80 fi 81 if [[ $OSTYPE = (dragonfly*|freebsd*) ]]; then 82 arguments+=( 83 '(-A)-I[prevent -A from being automatically set for the super-user]' 84 '(-1 -C -m -x)-D+[specify format for date]:format: _date_formats' 85 ) 86 fi 87 if [[ $OSTYPE = dragonfly* ]]; then 88 arguments+=( 89 '-_[use GMT based date and time output with nanotime timestamp]' 90 '-y[display FSMID in long listing]' 91 ) 92 fi 93 if [[ $OSTYPE = (freebsd*|darwin*) ]]; then 94 arguments+=( '(-c -u)-U[file creation time]' ) 95 fi 96 if [[ $OSTYPE = freebsd* ]]; then 97 arguments+=( 98 '-,[print file sizes grouped and separated by thousands]' 99 '-y[with -t, sort filenames in the same order as the time]' 100 '-Z[display MAC label]' 101 '--color=-[control use of color]:color:(never always auto)' 102 ) 103 fi 104 if [[ $OSTYPE = darwin* ]]; then 105 arguments+=( 106 '-@[display extended attribute keys and sizes in long listing]' 107 '-e[display ACL in long listing]' 108 '(-l -1 -C -m -x)-o[long listing but without group information]' 109 '-O[display file flags]' 110 '-v[print raw characters]' 111 ) 112 fi 113 if [[ $OSTYPE = solaris* ]]; then 114 arguments+=( 115 '(-q)-b[print octal escapes for control characters]' 116 '(-l -1 -C -m -x)-o[long listing but without group information]' 117 '(-l -t -s -r -a)-f[interpret each argument as a directory]' 118 '(-E -l)-e[long listing with full and consistent date/time]' 119 '(-e -l)-E[long listing with ISO format date/time]' 120 '-H[follow symlinks on the command line]' 121 '-v[long listing with verbose ACL information]' 122 '-V[long listing with compact ACL information]' 123 '-@[long listing with marker for extended attribute information]' 124 ) 125 fi 126else 127 [[ $PREFIX = *+* ]] && datef='formats:format: _date_formats' 128 arguments=( 129 '(--all -a -A --almost-all)'{--all,-a}'[list entries starting with .]' 130 '(--almost-all -A -a --all)'{--almost-all,-A}'[list all except . and ..]' 131 '--author[print the author of each file]' 132 '(--ignore-backups -B)'{--ignore-backups,-B}"[don't list entries ending with ~]" 133 '(--directory -d)'{--directory,-d}'[list directory entries instead of contents]' 134 '(--dired -D)'{--dired,-D}"[generate output designed for Emacs' dired mode]" 135 '*'{--ignore=,-I+}"[don't list entries matching pattern]:pattern: " 136 '(--dereference -L --dereference-command-line -H --dereference-command-line-symlink-to-dir)'{--dereference,-L}'[list referenced file for sym link]' 137 '(--dereference -L --dereference-command-line -H --dereference-command-line-symlink-to-dir)'{--dereference-command-line,-H}'[follow symlink on the command line]' 138 '(--dereference -L --dereference-command-line -H)'--dereference-command-line-symlink-to-dir 139 '(--recursive -R)'{--recursive,-R}'[list subdirectories recursively]' 140 141 '(--no-group -G)'{--no-group,-G}'[inhibit display of group information]' 142 '(--block-size --human-readable -h --si --kilobytes -k)'{--human-readable,-h}'[print sizes in human readable form]' 143 '(--block-size --human-readable -h --si --kilobytes -k)--si[sizes in human readable form; powers of 1000]' 144 '(--inode -i)'{--inode,-i}'[print file inode numbers]' 145 146 '(--format -l -g -o -1 -C -m -x)-l[long listing]' 147 '(--format -l -1 -C -m -x)-g[long listing but without owner information]' 148 --group-directories-first 149 '(--format -l --no-group -G -1 -C -m -x)-o[no group, long]' 150 '(--format -l -g -o -C -m -x)-1[single column output]' 151 '(--format -l -g -o -1 -m -x)-C[list entries in columns sorted vertically]' 152 '(--format -l -g -o -1 -C -x)-m[comma separated]' 153 '(--format -l -g -o -1 -C -m)-x[sort horizontally]' 154 '(-l -g -o -1 -C -m -x)--format=[specify output format]:format:(verbose long commas horizontal across vertical single-column)' 155 156 '(--size -s -f)'{--size,-s}'[display size of each file in blocks]' 157 158 '(--time -u)-c[status change time]' 159 '(--time -c)-u[access time]' 160 '(-c -u)--time=[specify time to show]:time:(ctime status use atime access)' 161 '--time-style=[show times using specified style]:style: _alternative "time-styles\:time style\:(full-iso long-iso iso locale)" $datef' 162 163 '(-a --all -U -l --format -s --size -t --sort --full-time)-f[unsorted, all, short list]' 164 '(--reverse -r -U -f)'{--reverse,-r}'[reverse sort order]' 165 166 '(--sort -t -U -v -X)-S[sort by size]' 167 '(--sort -S -U -v -X)-t[sort by modification time]' 168 '(--sort -S -t -v -X)-U[unsorted]' 169 '(--sort -S -t -U -X)-v[sort by version (filename treated numerically)]' 170 '(--sort -S -t -U -v)-X[sort by extension]' 171 '(-S -t -U -v -X)--sort=[specify sort key]:sort key:(size time none version extension)' 172 173 '--color=-[control use of color]:color:(never always auto)' 174 "*--hide=[like -I, but overridden by -a or -A]:pattern: " 175 '--hyperlink=[output terminal codes to link files using file::// URI]::when:(none auto always)' 176 '(--classify -F --indicator-style -p --file-type)'{--classify,-F}'[append file type indicators]' 177 '(--file-type -p --indicator-style -F --classify)--file-type[append file type indicators except *]' 178 '(--file-type -p --indicator-style -F --classify)-p[append / to directories]' 179 '(-F --classify -p --file-type)--indicator-style=[specify indicator style]:indicator style:(none file-type classify slash)' 180 181 '(-f)--full-time[list both full date and full time]' 182 183 '(--block-size --human-readable -h --si --kilobytes -k)'{--kilobytes,-k}'[use block size of 1k]' 184 '(--human-readable -h --si --kilobytes -k)--block-size=[specify block size]:block size (bytes):(K M G T P E Z Y KB MB TB PB EB ZB YB)' 185 186 '(--numeric-uid-gid -n)'{--numeric-uid-gid,-n}'[numeric uid, gid]' 187 '(--tabsize -T)'{--tabsize=,-T+}'[specify tab size]:tab size' 188 '(--width -w)'{--width=,-w+}'[specify screen width]:screen width' 189 190 '(--quoting-style -b --escape -N --literal -Q --quote-name)'{--escape,-b}'[print octal escapes for control characters]' 191 '(--quoting-style -b --escape -N --literal -Q --quote-name)'{--literal,-N}'[print entry names without quoting]' 192 '(--quoting-style -b --escape -N --literal -Q --quote-name)'{--quote-name,-Q}'[quote names]' 193 '(-b --escape -N --literal -Q --quote-name)--quoting-style=[specify quoting style]:quoting style:(literal shell shell-always c escape clocale locale)' 194 195 '(--hide-control-chars -q --show-control-chars)'{--hide-control-chars,-q}'[hide control chars]' 196 '(-q --hide-control-chars)--show-control-chars' 197 '(- :)--help[display help information]' 198 '(- :)--version[display version information]' 199 '*:files:_files' 200 ) 201 if [[ $OSTYPE = linux* ]]; then 202 arguments+=( 203 '(-Z --context)'{-Z,--context}'[print any security context of each file]' 204 ) 205 fi 206fi 207 208_arguments -s -S : $arguments 209