about summary refs log tree commit diff
path: root/Completion/Unix/Command/_ls
blob: 392b8490bd3f4a638f3b9be5e48d5f4a30f8a9bb (plain) (blame)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#compdef ls gls

local arguments is_gnu datef

if ! _pick_variant gnu=gnu unix --help; then
  arguments=(
    '(-A)-a[list entries starting with .]'
    '(-a)-A[list all except . and ..]'
    '-d[list directory entries instead of contents]'
    '-L[list referenced file for sym link]'
    '-R[list subdirectories recursively]'

    '(-k)-h[print sizes in human readable form]'
    '(-h)-k[print sizes in kilobytes]'

    '-i[print file inode numbers]'
    '(-l -g -1 -C -m -x)-l[long listing]'
    '(-l -g -C -m -x)-1[single column output]'
    '(-l -g -1 -m -x)-C[list entries in columns sorted vertically]'
    '(-l -g -1 -C -x)-m[comma separated]'
    '(-l -g -1 -C -m)-x[sort horizontally]'

    '-s[display size of each file in blocks]'

    '(-u)-c[status change time]'
    '(-c)-u[access time]'

    '-r[reverse sort order]'

    '(-t)-S[sort by size]'
    '(-S)-t[sort by modification time]'

    '(-p)-F[append file type indicators]'
    '(-F)-p[append file type indicators for directory]'

    '-n[numeric uid, gid]'

    '(-B -b -w -q)-q[hide control chars]'

    '*: :_files'
  )
  if [[ "$OSTYPE" = (netbsd*|dragonfly*|freebsd*|openbsd*|darwin*) ]]; then
    arguments+=(
      '-T[show complete time information]'
      '(-a -A -r -S -t)-f[output is not sorted]'
    )
  fi
  if [[ $OSTYPE = (netbsd*|dragonfly*|freebsd*|openbsd*) ]]; then
    arguments+=( '-o[display file flags]' )
  fi
  if [[ $OSTYPE = (netbsd*|dragonfly*|freebsd*|darwin*) ]]; then
    arguments+=(
      '(-B -b -w -q)-B[print octal escapes for control characters]'
      '(-B -b -w -q)-b[as -B, but use C escape codes whenever possible]'
      '(-B -b -w -q)-w[print raw characters]'
      '-W[display whiteouts when scanning directories]'
    )
  fi
  if [[ $OSTYPE = (netbsd*|openbsd*|darwin*|solaris*) ]]; then
    arguments+=(
      '(-l -1 -C -m -x)-g[long listing but without owner information]'
    )
  fi
  if [[ $OSTYPE = netbsd* ]]; then
    arguments+=(
      '-M[output file sizes in comma-separated form]'
      '-O[output only leaf (non-directory) files]'
      '-P[print full pathname for each file]'
      "-X[don't cross mount points when recursing]"
    )
  fi
  if [[ $OSTYPE = (dragonfly*|freebsd*|openbsd*|darwin*) ]]; then
    arguments+=( '-H[follow symlinks on the command line]' )
  fi
  if [[ $OSTYPE = (dragonfly*|freebsd*|darwin*) ]]; then
    arguments+=(
      '-G[enable colorized output]'
      '(-A)-I[prevent -A from being automatically set for the super-user]'
      '-P[do not follow symlinks]'
    )
  fi
  if [[ $OSTYPE = (dragonfly*|freebsd*) ]]; then
    arguments+=(
      '(-1 -C -m -x)-D+[specify format for date]:format: _date_formats'
    )
  fi
  if [[ $OSTYPE = dragonfly* ]]; then
    arguments+=(
      '-_[use GMT based date and time output with nanotime timestamp]'
      '-y[display FSMID in long listing]'
    )
  fi
  if [[ $OSTYPE = (freebsd*|darwin*) ]]; then
    arguments+=(
      '-,[print file sizes grouped and separated by thousands]'
      '(-c -u)-U[file creation time]'
      '-y[with -t, sort filenames in the same order as the time]'
      '--color=-[control use of color]:color:(never always auto)'
    )
  fi
  if [[ $OSTYPE = freebsd* ]]; then
    arguments+=(
      '(-S -f -t -U)-v[sort by version (filename treated numerically)]'
      '-Z[display MAC label]'
    )
  fi
  if [[ $OSTYPE = darwin* ]]; then
    arguments+=(
      '-@[display extended attribute keys and sizes in long listing]'
      '-e[display ACL in long listing]'
      '(-l -1 -C -m -x)-o[long listing but without group information]'
      '-O[display file flags]'
      '-v[print raw characters]'
      '-%[distinguish dataless files and directories with a %]'
    )
  fi
  if [[ $OSTYPE = solaris* ]]; then
    arguments+=(
      '(-q)-b[print octal escapes for control characters]'
      '(-l -1 -C -m -x)-o[long listing but without group information]'
      '(-l -t -s -r -a)-f[interpret each argument as a directory]'
      '(-E -l)-e[long listing with full and consistent date/time]'
      '(-e -l)-E[long listing with ISO format date/time]'
      '-H[follow symlinks on the command line]'
      '-v[long listing with verbose ACL information]'
      '-V[long listing with compact ACL information]'
      '-@[long listing with marker for extended attribute information]'
    )
  fi
else
  [[ $PREFIX = *+* ]] && datef='formats:format: _date_formats'
  arguments=(
    '(--all -a -A --almost-all)'{--all,-a}'[list entries starting with .]'
    '(--almost-all -A -a --all)'{--almost-all,-A}'[list all except . and ..]'
    '--author[print the author of each file]'
    '(--ignore-backups -B)'{--ignore-backups,-B}"[don't list entries ending with ~]"
    '(--directory -d)'{--directory,-d}'[list directory entries instead of contents]'
    '(--dired -D)'{--dired,-D}"[generate output designed for Emacs' dired mode]"
    '*'{--ignore=,-I+}"[don't list entries matching pattern]:pattern: "
    '(--dereference -L --dereference-command-line -H --dereference-command-line-symlink-to-dir)'{--dereference,-L}'[list referenced file for sym link]'
    '(--dereference -L --dereference-command-line -H --dereference-command-line-symlink-to-dir)'{--dereference-command-line,-H}'[follow symlink on the command line]'
    '(--dereference -L --dereference-command-line -H)'--dereference-command-line-symlink-to-dir
    '(--recursive -R)'{--recursive,-R}'[list subdirectories recursively]'

    '(--no-group -G)'{--no-group,-G}'[inhibit display of group information]'
    '(--block-size --human-readable -h --si --kibibytes -k)'{--human-readable,-h}'[print sizes in human readable form]'
    '(--block-size --human-readable -h --si --kibibytes -k)--si[sizes in human readable form; powers of 1000]'
    '(--inode -i)'{--inode,-i}'[print file inode numbers]'

    '(--format -l -g -o -1 -C -m -x)-l[long listing]'
    '(--format -l -1 -C -m -x)-g[long listing but without owner information]'
    --group-directories-first
    '(--format -l --no-group -G -1 -C -m -x)-o[no group, long]'
    '(--format -l -g -o -C -m -x)-1[single column output]'
    '(--format -l -g -o -1 -m -x --block-size --human-readable -h --si --kibibytes -k)-C[list entries in columns sorted vertically]'
    '(--format -l -g -o -1 -C -x --block-size --human-readable -h --si --kibibytes -k)-m[comma separated]'
    '(--format -l -g -o -1 -C -m --block-size --human-readable -h --si --kibibytes -k)-x[sort horizontally]'
    '(-l -g -o -1 -C -m -x)--format=[specify output format]:format:(verbose long commas horizontal across vertical single-column)'

    '(--size -s -f)'{--size,-s}'[display size of each file in blocks]'

    '(--time -u)-c[status change time]'
    '(--time -c)-u[access time]'
    '(-c -u)--time=[specify time to show]:time:(ctime status use atime access birth creation)'
    '--time-style=[show times using specified style]:style: _alternative "time-styles\:time style\:(full-iso long-iso iso locale)" $datef'

    '(-a --all -U -l --format -s --size -t --sort --full-time)-f[unsorted, all, short list]'
    '(--reverse -r -U -f)'{--reverse,-r}'[reverse sort order]'

    '(--sort -f -t -U -v -X)-S[sort by size]'
    '(--sort -f -S -U -v -X)-t[sort by modification time]'
    '(--sort -f -S -t -v -X)-U[unsorted]'
    '(--sort -f -S -t -U -X)-v[sort by version (filename treated numerically)]'
    '(--sort -f -S -t -U -v)-X[sort by extension]'
    '(-S -f -t -U -v -X)--sort=[specify sort key]:sort key:(size time none version extension)'

    '--color=-[control use of color]:color:(never always auto)'
    "*--hide=[like -I, but overridden by -a or -A]:pattern: "
    '--hyperlink=[output terminal codes to link files using file::// URI]::when:(none auto always)'
    '(--classify -F --indicator-style -p --file-type)-F[append file type indicators]'
    '(--classify -F --indicator-style -p --file-type)--classify=-[append file type indicators]::when [always]:(none auto always)'
    '(--file-type -p --indicator-style -F --classify)--file-type[append file type indicators except *]'
    '(--file-type -p --indicator-style -F --classify)-p[append / to directories]'
    '(-F --classify -p --file-type)--indicator-style=[specify indicator style]:indicator style:(none file-type classify slash)'

    '(-f)--full-time[list both full date and full time]'

    '(--block-size --human-readable -h --si --kibibytes -k)'{--kibibytes,-k}'[use block size of 1k]'
    '(--human-readable -h --si --kibibytes -k -C -x)--block-size=[specify block size]:block size (bytes):(K M G T P E Z Y KB MB TB PB EB ZB YB)'

    '(--numeric-uid-gid -n)'{--numeric-uid-gid,-n}'[numeric uid, gid]'
    '(--tabsize -T)'{--tabsize=,-T+}'[specify tab size]:tab size'
    '(--width -w)'{--width=,-w+}'[specify screen width]:screen width'

    '(--quoting-style -b --escape -N --literal -Q --quote-name)'{--escape,-b}'[print octal escapes for control characters]'
    '(--quoting-style -b --escape -N --literal -Q --quote-name)'{--literal,-N}'[print entry names without quoting]'
    '(--quoting-style -b --escape -N --literal -Q --quote-name)'{--quote-name,-Q}'[quote names]'
    '(-b --escape -N --literal -Q --quote-name)--quoting-style=[specify quoting style]:quoting style:(literal shell shell-always c escape clocale locale)'

    '(--hide-control-chars -q --show-control-chars)'{--hide-control-chars,-q}'[hide control chars]'
    '(-q --hide-control-chars)--show-control-chars'
    '--zero[end each output line with NUL, not newline]'
    '(- :)--help[display help information]'
    '(- :)--version[display version information]'
    '*:file:_files'
  )
  if [[ $OSTYPE = linux* ]]; then
    arguments+=(
      '(-Z --context)'{-Z,--context}'[print any security context of each file]'
    )
  fi
fi

_arguments -s -S : $arguments