blob: b1c4e398fd0d6e293b2bece7a894d0f21433979b (
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
#!/bin/zsh
# ^^^^^^^^ @comment @spell
# Basic comment
# <- @comment @spell
# Variables and assignments
name="value"
#^^^ @variable @constant
# ^ @operator
# ^^^^^^^ @string
export PATH="/usr/bin:$PATH"
#^^^^^ @keyword.import
# ^^^^ @variable @constant @variable.builtin
# ^ @operator
# ^^^^^^^^^^^^^^^^ @string
# ^ @punctuation.special
# ^^^^ @variable.builtin
# Function definition
function myfunction() {
#^^^^^^^ @keyword.function
# ^^^^^^^^^^ @function @number
echo "Hello World"
#^^^ @function.call @function.builtin @number
# ^^^^^^^^^^^^^ @string
}
myfunction() {
#^^^^^^^^^ @function @number
local var="test"
#^^^^ @keyword
# ^^^ @variable @constant
# ^ @operator
# ^^^^^^ @string
}
# Built-in commands
echo "Hello"
#^^^ @function.call @function.builtin @number
# ^^^^^^^ @string
cd /home/user
#^ @function.call @function.builtin @number
# ^^^^^^^^^^ @variable.parameter @number
ls -la
#^ @function.call @number
# ^^^ @variable.parameter @number
# Control structures
if [[ -f "$file" ]]; then
#^ @keyword.conditional
# ^^ @punctuation.bracket
# ^^ @operator @operator
# ^^^^^^^ @string
# ^ @punctuation.special @none
# ^^ @punctuation.bracket
# ^ @punctuation.delimiter
# ^^^^ @keyword.conditional
echo "File exists"
#^^^ @function.call @function.builtin @number
# ^^^^^^^^^^^^^ @string
fi
#^ @keyword.conditional
for i in {1..10}; do
#^^ @keyword.repeat
# ^^ @keyword.conditional
# ^ @punctuation.bracket
# ^ @number
# ^^ @operator
# ^^ @number
# ^ @punctuation.bracket
# ^ @punctuation.delimiter
# ^^ @keyword.repeat
echo $i
#^^^ @function.call @function.builtin @number
# ^ @punctuation.special
done
#^^^ @keyword.repeat
while read line; do
#^^^^ @keyword.repeat
# ^^^^ @function.call @function.builtin @number
# ^^^^ @variable.parameter @number
# ^ @punctuation.delimiter
# ^^ @keyword.repeat
echo "$line"
#^^^ @function.call @function.builtin @number
# ^^^^^^^ @string
# ^ @punctuation.special @none
done
#^^^ @keyword.repeat
case $input in
#^^^ @keyword.conditional
# ^ @punctuation.special @none
# ^^ @keyword.conditional
"yes"|"y")
#^^^^ @string @variable.parameter
# ^ @operator
# ^^^ @string @variable.parameter
# ^ @punctuation.bracket
echo "Yes"
#^^^ @function.call @function.builtin @number
# ^^^^^ @string
;;
#^ @punctuation.delimiter
"no"|"n")
#^^^ @string @variable.parameter
# ^ @operator
# ^^^ @string @variable.parameter
# ^ @punctuation.bracket
echo "No"
#^^^ @function.call @function.builtin @number
# ^^^^ @string
;;
#^ @punctuation.delimiter
*)
#^ @string.regexp
# ^ @punctuation.bracket
echo "Unknown"
#^^^ @function.call @function.builtin @number
# ^^^^^^^^^ @string
;;
#^ @punctuation.delimiter
esac
#^^^ @keyword.conditional
# Arrays
arr=(one two three)
#^^ @variable @constant
# ^ @operator
# ^ @punctuation.bracket
# ^ @punctuation.bracket
echo ${arr[1]}
#^^^ @function.call @function.builtin @number
# ^ @punctuation.special
# ^ @punctuation.special
# ^ @punctuation.bracket
# ^ @number
# ^ @punctuation.bracket
# ^ @punctuation.special
# Parameter expansion
echo ${name:-default}
#^^^ @function.call @function.builtin @number
# ^^ @punctuation.special
# ^ @punctuation.special
echo ${#name}
#^^^ @function.call @function.builtin @number
# ^^ @punctuation.special
# ^ @punctuation.special
# Command substitution
result=$(date)
#^^^^^ @variable @constant
# ^ @operator
# ^ @punctuation.special
# ^ @punctuation.special
# ^^^^ @function.call @number
# ^ @punctuation.special
result=`date`
#^^^^^ @variable @constant
# ^ @operator
# ^^^^ @function.call @number
# Pipes and redirection
ls | grep "test" > output.txt
#^ @function.call @number
# ^ @operator
# ^^^^ @function.call @number
# ^^^^^^ @string
# ^ @operator
# ^^^^^^^^^^ @string.special.path @number
cat < input.txt >> output.txt
#^^ @function.call @number
# ^ @operator
# ^^^^^^^^^ @string.special.path @number
# ^^ @operator
# ^^^^^^^^^^ @string.special.path @number
# Process substitution
diff <(ls dir1) <(ls dir2)
#^^^ @function.call @number
# ^ @punctuation.special
# ^ @punctuation.special
# ^^ @function.call @number
# ^^^^ @variable.parameter @number
# ^^ @punctuation.special
# ^^ @function.call @number
# ^^^^ @variable.parameter @number
# ^ @punctuation.special @punctuation.bracket
# Test commands
[[ -f file.txt ]]
#^ @punctuation.bracket
# ^^ @operator @operator
# ^^ @punctuation.bracket
[ -n "$var" ]
#^ @punctuation.bracket
# ^^ @operator @operator
# ^^^^^ @string
# ^ @punctuation.special
# ^ @punctuation.bracket
# Arithmetic expansion
echo $((2 + 3))
#^^^ @function.call @function.builtin @number
# ^ @punctuation.special
# ^^ @punctuation.special
# ^ @number
# ^ @operator
# ^ @number
# ^^ @punctuation.special @punctuation.bracket
# Globbing patterns
ls *.txt
#^ @function.call @number
# Brace expansion
echo {a,b,c}
#^^^ @function.call @function.builtin @number
# Here documents
cat << EOF
#^^ @function.call @number
# ^^ @operator
# ^^^ @label
This is a heredoc
#^^^^^^^^^^^^^^^^^ @string
EOF
#^^ @label
cat <<< "string"
#^^ @function.call @number
# ^^ @operator
# ^ @operator
# ^^^^^^^^ @string
# Special variables
echo $0 $1 $@ $* $# $?
#^^^ @function.call @function.builtin @number
# ^^ @punctuation.special @none @variable.builtin
# ^ @variable.builtin
# ^^ @punctuation.special @none @variable.builtin
# ^ @variable.builtin
# ^^ @punctuation.special @none @variable.builtin
# ^ @variable.builtin
# ^^ @punctuation.special @none @variable.builtin
# ^ @variable.builtin
# ^^ @punctuation.special @none @variable.builtin
# ^ @variable.builtin
# ^^ @punctuation.special @none @variable.builtin
# ^ @variable.builtin
# NOTE: $$ is not captured by current query/grammar
# Conditional operators
[[ $a == $b ]] && echo "equal"
#^ @punctuation.bracket
# ^ @punctuation.special @none
# ^^ @operator @operator
# ^ @punctuation.special @none
# ^^ @punctuation.bracket
# ^^ @operator
# ^^^^ @function.builtin @function.call @number
# ^^^^^^^ @string
[[ $a != $b ]] || echo "not equal"
#^ @punctuation.bracket
# ^^ @punctuation.special @none
# ^^ @operator
# ^^ @punctuation.special @none
# ^^ @operator
# ^^^^ @function.call @function.builtin @number
# ^^^^^^^^^^^ @string
# Background jobs
sleep 10 &
#^^^^ @function.call @number
# ^^ @number
# ^ @punctuation.delimiter
# Negation
! command
#^ @operator
#^^^^^^ @function.call @number
# File descriptors
exec 3> file.txt
#^^^ @function.call @function.builtin @number
# ^ @operator
# ^ @operator
# ^^^^^^^^ @string.special.path @number
# ZSH-specific features
setopt AUTO_CD
#^^^^^ @function.call @number
# ^^^^^^^ @variable.parameter @number
autoload -U compinit
#^^^^^^^ @function.call @number
# ^^ @variable.parameter @number
# ^^^^^^^^ @variable.parameter @number
# Associative arrays
typeset -A hash
#^^^^^^ @keyword
# ^^ @variable.parameter @number
# ^^^^ @variable.parameter @constant
hash[key]="value"
#^^^ @variable @constant
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ @operator
# ^^^^^^^ @string
# Regular expressions
[[ "text" =~ ^[a-z]+$ ]]
#^ @punctuation.bracket
# ^^^^^^ @string
# ^^ @operator
# ^^^^^^^^^ @string.regexp
# ^^ @punctuation.bracket
# Quotes and escaping
echo "double quotes with $var"
#^^^ @function.call @function.builtin @number
# ^^^^^^^^^^^^^^^^^^^^^^^^^ @string
# ^ @punctuation.special @none
echo 'single quotes $var'
#^^^ @function.call @function.builtin @number
# ^^^^^^^^^^^^^^^^^^^^ @string
echo $'ansi-c quotes\n'
#^^^ @function.call @function.builtin @number
# ^^^^^^^^^^^^^^^^^ @string
echo "escaped \" quote"
#^^^ @function.call @function.builtin @number
# ^^^^^^^^^^^^^^^^^^ @string
# Command chaining
cmd1 && cmd2 || cmd3
#^^^ @function.call @number
# ^^ @operator
# ^^^^ @function.call @number
# ^^ @operator
# ^^^^ @function.call @number
|