@enjoys/context-engine 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/commands/adb.json +322 -0
- package/data/commands/alembic.json +301 -0
- package/data/commands/artisan.json +277 -0
- package/data/commands/atlas.json +426 -0
- package/data/commands/auth0.json +648 -0
- package/data/commands/bat.json +84 -0
- package/data/commands/btop.json +59 -0
- package/data/commands/bundle.json +321 -0
- package/data/commands/composer.json +507 -0
- package/data/commands/dart.json +216 -0
- package/data/commands/dbmate.json +257 -0
- package/data/commands/docker-compose.json +384 -0
- package/data/commands/drizzle-kit.json +217 -0
- package/data/commands/expo.json +65 -0
- package/data/commands/fastlane.json +243 -0
- package/data/commands/fd.json +86 -0
- package/data/commands/flutter.json +298 -0
- package/data/commands/flyway.json +261 -0
- package/data/commands/fzf.json +103 -0
- package/data/commands/gem.json +267 -0
- package/data/commands/htop.json +56 -0
- package/data/commands/jq.json +100 -0
- package/data/commands/k9s.json +62 -0
- package/data/commands/linux.json +3007 -0
- package/data/commands/liquibase.json +399 -0
- package/data/commands/manifest.json +619 -0
- package/data/commands/minikube.json +60 -0
- package/data/commands/ng.json +64 -0
- package/data/commands/nuxt.json +60 -0
- package/data/commands/nvim.json +91 -0
- package/data/commands/php.json +157 -0
- package/data/commands/pm2.json +259 -0
- package/data/commands/pod.json +175 -0
- package/data/commands/prisma.json +257 -0
- package/data/commands/rails.json +372 -0
- package/data/commands/rake.json +360 -0
- package/data/commands/react-native.json +57 -0
- package/data/commands/rg.json +103 -0
- package/data/commands/rspec.json +257 -0
- package/data/commands/ruby.json +108 -0
- package/data/commands/screen.json +101 -0
- package/data/commands/sequelize.json +342 -0
- package/data/commands/snyk.json +442 -0
- package/data/commands/sonar-scanner.json +219 -0
- package/data/commands/stripe.json +314 -0
- package/data/commands/symfony.json +449 -0
- package/data/commands/tmux.json +197 -0
- package/data/commands/top.json +61 -0
- package/data/commands/trivy.json +367 -0
- package/data/commands/twilio.json +382 -0
- package/data/commands/typeorm.json +262 -0
- package/data/commands/vim.json +85 -0
- package/data/commands/vue.json +60 -0
- package/data/commands/wp.json +857 -0
- package/data/commands/xcodebuild.json +141 -0
- package/data/commands/yq.json +57 -0
- package/data/completion/bash.json +1184 -0
- package/data/completion/c.json +1067 -0
- package/data/completion/cpp.json +824 -0
- package/data/completion/csharp.json +860 -0
- package/data/completion/dockerfile.json +536 -0
- package/data/completion/go.json +1346 -0
- package/data/completion/html.json +806 -0
- package/data/completion/java.json +1112 -0
- package/data/completion/javascript.json +914 -0
- package/data/completion/lua.json +968 -0
- package/data/completion/php.json +1535 -0
- package/data/completion/python.json +1427 -0
- package/data/completion/ruby.json +1531 -0
- package/data/completion/rust.json +698 -0
- package/data/completion/sql.json +887 -0
- package/data/completion/toml.json +428 -0
- package/data/completion/typescript.json +338 -0
- package/data/completion/yaml.json +563 -0
- package/data/defination/bash.json +565 -0
- package/data/defination/c.json +865 -0
- package/data/defination/cpp.json +348 -0
- package/data/defination/csharp.json +144 -0
- package/data/defination/dockerfile.json +113 -0
- package/data/defination/go.json +561 -0
- package/data/defination/html.json +559 -0
- package/data/defination/java.json +184 -0
- package/data/defination/javascript.json +265 -0
- package/data/defination/lua.json +181 -0
- package/data/defination/php.json +726 -0
- package/data/defination/python.json +717 -0
- package/data/defination/ruby.json +670 -0
- package/data/defination/rust.json +207 -0
- package/data/defination/sql.json +473 -0
- package/data/defination/toml.json +251 -0
- package/data/defination/typescript.json +29 -0
- package/data/defination/yaml.json +197 -0
- package/data/hover/bash.json +245 -0
- package/data/hover/c.json +265 -0
- package/data/hover/cpp.json +210 -0
- package/data/hover/csharp.json +290 -0
- package/data/hover/dockerfile.json +145 -0
- package/data/hover/go.json +580 -0
- package/data/hover/html.json +250 -0
- package/data/hover/java.json +395 -0
- package/data/hover/javascript.json +330 -0
- package/data/hover/lua.json +265 -0
- package/data/hover/php.json +300 -0
- package/data/hover/python.json +380 -0
- package/data/hover/ruby.json +265 -0
- package/data/hover/rust.json +275 -0
- package/data/hover/sql.json +230 -0
- package/data/hover/toml.json +145 -0
- package/data/hover/typescript.json +120 -0
- package/data/hover/yaml.json +165 -0
- package/data/manifest.json +242 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
{
|
|
2
|
+
"language": "bash",
|
|
3
|
+
"completions": [
|
|
4
|
+
{
|
|
5
|
+
"label": "echo",
|
|
6
|
+
"kind": 1,
|
|
7
|
+
"detail": "Display a line of text",
|
|
8
|
+
"documentation": { "value": "Write arguments to stdout.\n\n```bash\necho \"Hello, world!\"\necho -n \"No newline\"\necho -e \"Tab:\\tNewline:\\n\"\n```" },
|
|
9
|
+
"insertText": "echo ${1:message}",
|
|
10
|
+
"insertTextRules": 4,
|
|
11
|
+
"sortText": "00_echo"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"label": "printf",
|
|
15
|
+
"kind": 1,
|
|
16
|
+
"detail": "Format and print data",
|
|
17
|
+
"documentation": { "value": "Formats and prints arguments under control of a format string.\n\n```bash\nprintf \"Name: %s, Age: %d\\n\" \"Alice\" 30\nprintf \"%05d\\n\" 42\nprintf -v var \"formatted %s\" \"string\"\n```" },
|
|
18
|
+
"insertText": "printf \"${1:format}\" ${2:arguments}",
|
|
19
|
+
"insertTextRules": 4,
|
|
20
|
+
"sortText": "00_printf"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"label": "read",
|
|
24
|
+
"kind": 1,
|
|
25
|
+
"detail": "Read a line from stdin",
|
|
26
|
+
"documentation": { "value": "Read a line from standard input and split it into fields.\n\n```bash\nread -p \"Enter name: \" name\nread -r line\nread -a array_var\nread -t 5 -p \"Timeout in 5s: \" answer\n```" },
|
|
27
|
+
"insertText": "read -r ${1:variable}",
|
|
28
|
+
"insertTextRules": 4,
|
|
29
|
+
"sortText": "00_read"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"label": "cd",
|
|
33
|
+
"kind": 1,
|
|
34
|
+
"detail": "Change the current directory",
|
|
35
|
+
"documentation": { "value": "Change the shell working directory.\n\n```bash\ncd /path/to/dir\ncd ~\ncd - # go to previous directory\ncd .. # go up one level\n```" },
|
|
36
|
+
"insertText": "cd ${1:directory}",
|
|
37
|
+
"insertTextRules": 4,
|
|
38
|
+
"sortText": "00_cd"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"label": "pwd",
|
|
42
|
+
"kind": 1,
|
|
43
|
+
"detail": "Print working directory",
|
|
44
|
+
"documentation": { "value": "Print the name of the current working directory.\n\n```bash\npwd\npwd -P # resolve symlinks\npwd -L # use logical path (default)\n```" },
|
|
45
|
+
"insertText": "pwd",
|
|
46
|
+
"insertTextRules": 4,
|
|
47
|
+
"sortText": "00_pwd"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"label": "export",
|
|
51
|
+
"kind": 14,
|
|
52
|
+
"detail": "Set environment variable",
|
|
53
|
+
"documentation": { "value": "Mark a variable for export to child processes.\n\n```bash\nexport PATH=\"/usr/local/bin:$PATH\"\nexport MY_VAR=\"value\"\nexport -n MY_VAR # unexport\nexport -p # list all exported\n```" },
|
|
54
|
+
"insertText": "export ${1:VAR}=\"${2:value}\"",
|
|
55
|
+
"insertTextRules": 4,
|
|
56
|
+
"sortText": "00_export"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"label": "source",
|
|
60
|
+
"kind": 1,
|
|
61
|
+
"detail": "Execute commands from a file in the current shell",
|
|
62
|
+
"documentation": { "value": "Read and execute commands from a file in the current shell environment.\n\n```bash\nsource ~/.bashrc\nsource ./config.sh\n. ./env.sh # shorthand for source\n```" },
|
|
63
|
+
"insertText": "source ${1:file}",
|
|
64
|
+
"insertTextRules": 4,
|
|
65
|
+
"sortText": "00_source"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"label": "alias",
|
|
69
|
+
"kind": 1,
|
|
70
|
+
"detail": "Define or display aliases",
|
|
71
|
+
"documentation": { "value": "Create a shortcut name for a command.\n\n```bash\nalias ll='ls -la'\nalias gs='git status'\nalias # list all aliases\nalias ll # show specific alias\n```" },
|
|
72
|
+
"insertText": "alias ${1:name}='${2:command}'",
|
|
73
|
+
"insertTextRules": 4,
|
|
74
|
+
"sortText": "00_alias"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"label": "unalias",
|
|
78
|
+
"kind": 1,
|
|
79
|
+
"detail": "Remove alias definitions",
|
|
80
|
+
"documentation": { "value": "Remove alias definitions.\n\n```bash\nunalias ll\nunalias -a # remove all aliases\n```" },
|
|
81
|
+
"insertText": "unalias ${1:name}",
|
|
82
|
+
"insertTextRules": 4,
|
|
83
|
+
"sortText": "00_unalias"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"label": "type",
|
|
87
|
+
"kind": 1,
|
|
88
|
+
"detail": "Describe a command",
|
|
89
|
+
"documentation": { "value": "Indicate how a command name would be interpreted.\n\n```bash\ntype ls # ls is aliased to ...\ntype cd # cd is a shell builtin\ntype -t echo # builtin\ntype -a echo # show all locations\n```" },
|
|
90
|
+
"insertText": "type ${1:command}",
|
|
91
|
+
"insertTextRules": 4,
|
|
92
|
+
"sortText": "00_type"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"label": "which",
|
|
96
|
+
"kind": 1,
|
|
97
|
+
"detail": "Locate a command",
|
|
98
|
+
"documentation": { "value": "Show the full path of a command.\n\n```bash\nwhich python\nwhich -a node # show all matches\n```" },
|
|
99
|
+
"insertText": "which ${1:command}",
|
|
100
|
+
"insertTextRules": 4,
|
|
101
|
+
"sortText": "00_which"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"label": "eval",
|
|
105
|
+
"kind": 1,
|
|
106
|
+
"detail": "Evaluate arguments as a shell command",
|
|
107
|
+
"documentation": { "value": "Concatenate arguments and execute them as a shell command.\n\n```bash\ncmd=\"ls -la\"\neval \"$cmd\"\neval \"echo \\$HOME\"\n```" },
|
|
108
|
+
"insertText": "eval \"${1:command}\"",
|
|
109
|
+
"insertTextRules": 4,
|
|
110
|
+
"sortText": "00_eval"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"label": "exec",
|
|
114
|
+
"kind": 1,
|
|
115
|
+
"detail": "Replace the shell with a command",
|
|
116
|
+
"documentation": { "value": "Replace the shell process with the specified command, or redirect file descriptors.\n\n```bash\nexec /bin/zsh\nexec > output.log 2>&1 # redirect all output\nexec 3< input.txt # open fd 3 for reading\n```" },
|
|
117
|
+
"insertText": "exec ${1:command}",
|
|
118
|
+
"insertTextRules": 4,
|
|
119
|
+
"sortText": "00_exec"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"label": "exit",
|
|
123
|
+
"kind": 14,
|
|
124
|
+
"detail": "Exit the shell",
|
|
125
|
+
"documentation": { "value": "Exit the shell with a status code.\n\n```bash\nexit 0 # success\nexit 1 # general error\nexit # exit with last command's status\n```" },
|
|
126
|
+
"insertText": "exit ${1:0}",
|
|
127
|
+
"insertTextRules": 4,
|
|
128
|
+
"sortText": "00_exit"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"label": "return",
|
|
132
|
+
"kind": 14,
|
|
133
|
+
"detail": "Return from a function",
|
|
134
|
+
"documentation": { "value": "Return from a shell function with a status code.\n\n```bash\nmy_func() {\n if [[ -z \"$1\" ]]; then\n return 1\n fi\n return 0\n}\n```" },
|
|
135
|
+
"insertText": "return ${1:0}",
|
|
136
|
+
"insertTextRules": 4,
|
|
137
|
+
"sortText": "00_return"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"label": "shift",
|
|
141
|
+
"kind": 1,
|
|
142
|
+
"detail": "Shift positional parameters",
|
|
143
|
+
"documentation": { "value": "Shift positional parameters to the left by n positions (default 1).\n\n```bash\nwhile [[ $# -gt 0 ]]; do\n echo \"$1\"\n shift\ndone\nshift 2 # shift by 2 positions\n```" },
|
|
144
|
+
"insertText": "shift ${1:1}",
|
|
145
|
+
"insertTextRules": 4,
|
|
146
|
+
"sortText": "00_shift"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"label": "trap",
|
|
150
|
+
"kind": 1,
|
|
151
|
+
"detail": "Trap signals and events",
|
|
152
|
+
"documentation": { "value": "Execute a command when the shell receives a signal.\n\n```bash\ntrap 'echo Interrupted' INT\ntrap 'rm -f /tmp/tmpfile; exit' EXIT\ntrap '' SIGTERM # ignore SIGTERM\ntrap - INT # reset to default\n```" },
|
|
153
|
+
"insertText": "trap '${1:command}' ${2:SIGNAL}",
|
|
154
|
+
"insertTextRules": 4,
|
|
155
|
+
"sortText": "00_trap"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"label": "set",
|
|
159
|
+
"kind": 1,
|
|
160
|
+
"detail": "Set or unset shell options",
|
|
161
|
+
"documentation": { "value": "Set shell options and positional parameters.\n\n```bash\nset -e # exit on error\nset -u # error on unset variables\nset -o pipefail # fail on pipe errors\nset -x # print commands before execution\nset -- \"a\" \"b\" # set positional params\n```" },
|
|
162
|
+
"insertText": "set -${1:euo} pipefail",
|
|
163
|
+
"insertTextRules": 4,
|
|
164
|
+
"sortText": "00_set"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"label": "unset",
|
|
168
|
+
"kind": 1,
|
|
169
|
+
"detail": "Unset variables or functions",
|
|
170
|
+
"documentation": { "value": "Remove variable or function definitions.\n\n```bash\nunset MY_VAR\nunset -f my_function\nunset -v my_variable\n```" },
|
|
171
|
+
"insertText": "unset ${1:variable}",
|
|
172
|
+
"insertTextRules": 4,
|
|
173
|
+
"sortText": "00_unset"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"label": "declare",
|
|
177
|
+
"kind": 14,
|
|
178
|
+
"detail": "Declare variables and attributes",
|
|
179
|
+
"documentation": { "value": "Declare variables and set attributes.\n\n```bash\ndeclare -i num=42 # integer\ndeclare -r CONST=\"val\" # readonly\ndeclare -a arr=(1 2 3) # indexed array\ndeclare -A map # associative array\ndeclare -x VAR=\"val\" # export\ndeclare -l lower=\"ABC\" # lowercase\ndeclare -u upper=\"abc\" # uppercase\n```" },
|
|
180
|
+
"insertText": "declare -${1:i} ${2:variable}=${3:value}",
|
|
181
|
+
"insertTextRules": 4,
|
|
182
|
+
"sortText": "00_declare"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"label": "local",
|
|
186
|
+
"kind": 14,
|
|
187
|
+
"detail": "Declare local variable in function",
|
|
188
|
+
"documentation": { "value": "Create a local variable visible only within a function.\n\n```bash\nmy_func() {\n local name=\"Alice\"\n local -i count=0\n local -a items=(a b c)\n}\n```" },
|
|
189
|
+
"insertText": "local ${1:variable}=\"${2:value}\"",
|
|
190
|
+
"insertTextRules": 4,
|
|
191
|
+
"sortText": "00_local"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"label": "readonly",
|
|
195
|
+
"kind": 14,
|
|
196
|
+
"detail": "Mark variables as read-only",
|
|
197
|
+
"documentation": { "value": "Mark variables or functions as readonly.\n\n```bash\nreadonly PI=3.14159\nreadonly -a COLORS=(red green blue)\nreadonly -f my_func\n```" },
|
|
198
|
+
"insertText": "readonly ${1:variable}=\"${2:value}\"",
|
|
199
|
+
"insertTextRules": 4,
|
|
200
|
+
"sortText": "00_readonly"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"label": "if",
|
|
204
|
+
"kind": 14,
|
|
205
|
+
"detail": "Conditional statement",
|
|
206
|
+
"documentation": { "value": "Execute commands based on a condition.\n\n```bash\nif [[ condition ]]; then\n commands\nelif [[ condition ]]; then\n commands\nelse\n commands\nfi\n```" },
|
|
207
|
+
"insertText": "if [[ ${1:condition} ]]; then\n\t${2:commands}\nfi",
|
|
208
|
+
"insertTextRules": 4,
|
|
209
|
+
"sortText": "01_if"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"label": "then",
|
|
213
|
+
"kind": 14,
|
|
214
|
+
"detail": "Then clause of if statement",
|
|
215
|
+
"documentation": { "value": "Begins the body of an `if` or `elif` conditional block." },
|
|
216
|
+
"insertText": "then",
|
|
217
|
+
"insertTextRules": 4,
|
|
218
|
+
"sortText": "01_then"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"label": "elif",
|
|
222
|
+
"kind": 14,
|
|
223
|
+
"detail": "Else-if clause",
|
|
224
|
+
"documentation": { "value": "Additional condition check within an `if` block.\n\n```bash\nif [[ $x -eq 1 ]]; then\n echo \"one\"\nelif [[ $x -eq 2 ]]; then\n echo \"two\"\nfi\n```" },
|
|
225
|
+
"insertText": "elif [[ ${1:condition} ]]; then\n\t${2:commands}",
|
|
226
|
+
"insertTextRules": 4,
|
|
227
|
+
"sortText": "01_elif"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"label": "else",
|
|
231
|
+
"kind": 14,
|
|
232
|
+
"detail": "Else clause",
|
|
233
|
+
"documentation": { "value": "Default branch when no `if`/`elif` conditions are true." },
|
|
234
|
+
"insertText": "else\n\t${1:commands}",
|
|
235
|
+
"insertTextRules": 4,
|
|
236
|
+
"sortText": "01_else"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"label": "fi",
|
|
240
|
+
"kind": 14,
|
|
241
|
+
"detail": "End if statement",
|
|
242
|
+
"documentation": { "value": "Closes an `if` conditional block." },
|
|
243
|
+
"insertText": "fi",
|
|
244
|
+
"insertTextRules": 4,
|
|
245
|
+
"sortText": "01_fi"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"label": "for",
|
|
249
|
+
"kind": 14,
|
|
250
|
+
"detail": "For loop",
|
|
251
|
+
"documentation": { "value": "Iterate over a list of items.\n\n```bash\nfor item in \"${list[@]}\"; do\n echo \"$item\"\ndone\n\nfor i in {1..10}; do\n echo \"$i\"\ndone\n\nfor ((i=0; i<10; i++)); do\n echo \"$i\"\ndone\n```" },
|
|
252
|
+
"insertText": "for ${1:item} in ${2:list}; do\n\t${3:commands}\ndone",
|
|
253
|
+
"insertTextRules": 4,
|
|
254
|
+
"sortText": "01_for"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"label": "while",
|
|
258
|
+
"kind": 14,
|
|
259
|
+
"detail": "While loop",
|
|
260
|
+
"documentation": { "value": "Execute commands while a condition is true.\n\n```bash\nwhile [[ condition ]]; do\n commands\ndone\n\nwhile read -r line; do\n echo \"$line\"\ndone < file.txt\n```" },
|
|
261
|
+
"insertText": "while ${1:condition}; do\n\t${2:commands}\ndone",
|
|
262
|
+
"insertTextRules": 4,
|
|
263
|
+
"sortText": "01_while"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"label": "until",
|
|
267
|
+
"kind": 14,
|
|
268
|
+
"detail": "Until loop",
|
|
269
|
+
"documentation": { "value": "Execute commands until a condition becomes true.\n\n```bash\nuntil [[ $count -ge 10 ]]; do\n ((count++))\ndone\n```" },
|
|
270
|
+
"insertText": "until ${1:condition}; do\n\t${2:commands}\ndone",
|
|
271
|
+
"insertTextRules": 4,
|
|
272
|
+
"sortText": "01_until"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"label": "do",
|
|
276
|
+
"kind": 14,
|
|
277
|
+
"detail": "Begin loop body",
|
|
278
|
+
"documentation": { "value": "Marks the beginning of the loop body in `for`, `while`, `until`, and `select` loops." },
|
|
279
|
+
"insertText": "do",
|
|
280
|
+
"insertTextRules": 4,
|
|
281
|
+
"sortText": "01_do"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"label": "done",
|
|
285
|
+
"kind": 14,
|
|
286
|
+
"detail": "End loop body",
|
|
287
|
+
"documentation": { "value": "Marks the end of a `for`, `while`, `until`, or `select` loop." },
|
|
288
|
+
"insertText": "done",
|
|
289
|
+
"insertTextRules": 4,
|
|
290
|
+
"sortText": "01_done"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"label": "case",
|
|
294
|
+
"kind": 14,
|
|
295
|
+
"detail": "Case statement",
|
|
296
|
+
"documentation": { "value": "Pattern matching conditional.\n\n```bash\ncase \"$value\" in\n pattern1) commands ;;\n pattern2|pattern3) commands ;;\n *) default_commands ;;\nesac\n```" },
|
|
297
|
+
"insertText": "case \"${1:variable}\" in\n\t${2:pattern})\n\t\t${3:commands}\n\t\t;;\n\t*)\n\t\t${4:default}\n\t\t;;\nesac",
|
|
298
|
+
"insertTextRules": 4,
|
|
299
|
+
"sortText": "01_case"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"label": "esac",
|
|
303
|
+
"kind": 14,
|
|
304
|
+
"detail": "End case statement",
|
|
305
|
+
"documentation": { "value": "Closes a `case` pattern matching block." },
|
|
306
|
+
"insertText": "esac",
|
|
307
|
+
"insertTextRules": 4,
|
|
308
|
+
"sortText": "01_esac"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"label": "select",
|
|
312
|
+
"kind": 14,
|
|
313
|
+
"detail": "Select loop for menus",
|
|
314
|
+
"documentation": { "value": "Create a numbered menu for user selection.\n\n```bash\nselect opt in \"Option 1\" \"Option 2\" \"Quit\"; do\n case $opt in\n \"Option 1\") echo \"Selected 1\" ;;\n \"Option 2\") echo \"Selected 2\" ;;\n \"Quit\") break ;;\n *) echo \"Invalid\" ;;\n esac\ndone\n```" },
|
|
315
|
+
"insertText": "select ${1:opt} in ${2:options}; do\n\t${3:commands}\ndone",
|
|
316
|
+
"insertTextRules": 4,
|
|
317
|
+
"sortText": "01_select"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"label": "break",
|
|
321
|
+
"kind": 14,
|
|
322
|
+
"detail": "Exit from a loop",
|
|
323
|
+
"documentation": { "value": "Exit from a `for`, `while`, `until`, or `select` loop.\n\n```bash\nbreak # break innermost loop\nbreak 2 # break out of 2 nested loops\n```" },
|
|
324
|
+
"insertText": "break",
|
|
325
|
+
"insertTextRules": 4,
|
|
326
|
+
"sortText": "01_break"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"label": "continue",
|
|
330
|
+
"kind": 14,
|
|
331
|
+
"detail": "Skip to next loop iteration",
|
|
332
|
+
"documentation": { "value": "Resume the next iteration of a loop.\n\n```bash\ncontinue # skip to next iteration\ncontinue 2 # continue outer loop\n```" },
|
|
333
|
+
"insertText": "continue",
|
|
334
|
+
"insertTextRules": 4,
|
|
335
|
+
"sortText": "01_continue"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"label": "function",
|
|
339
|
+
"kind": 14,
|
|
340
|
+
"detail": "Define a function",
|
|
341
|
+
"documentation": { "value": "Define a shell function.\n\n```bash\nfunction greet() {\n echo \"Hello, $1!\"\n}\n\n# or without 'function' keyword:\ngreet() {\n echo \"Hello, $1!\"\n}\n```" },
|
|
342
|
+
"insertText": "${1:function_name}() {\n\t${2:commands}\n}",
|
|
343
|
+
"insertTextRules": 4,
|
|
344
|
+
"sortText": "01_function"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"label": "grep",
|
|
348
|
+
"kind": 1,
|
|
349
|
+
"detail": "Search text using patterns",
|
|
350
|
+
"documentation": { "value": "Search for lines matching a pattern.\n\n```bash\ngrep \"pattern\" file.txt\ngrep -r \"TODO\" ./src\ngrep -i -n \"error\" log.txt\ngrep -E \"^[0-9]+\" data.txt\ngrep -v \"exclude\" file.txt\ngrep -c \"count\" file.txt\n```" },
|
|
351
|
+
"insertText": "grep ${1:-r} \"${2:pattern}\" ${3:file}",
|
|
352
|
+
"insertTextRules": 4,
|
|
353
|
+
"sortText": "02_grep"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"label": "sed",
|
|
357
|
+
"kind": 1,
|
|
358
|
+
"detail": "Stream editor for text transformation",
|
|
359
|
+
"documentation": { "value": "Transform text using patterns and commands.\n\n```bash\nsed 's/old/new/g' file.txt\nsed -i 's/old/new/g' file.txt # in-place edit\nsed -n '10,20p' file.txt # print lines 10-20\nsed '/pattern/d' file.txt # delete matching lines\nsed '1i\\Header line' file.txt # insert at line 1\n```" },
|
|
360
|
+
"insertText": "sed '${1:s/old/new/g}' ${2:file}",
|
|
361
|
+
"insertTextRules": 4,
|
|
362
|
+
"sortText": "02_sed"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"label": "awk",
|
|
366
|
+
"kind": 1,
|
|
367
|
+
"detail": "Pattern scanning and processing",
|
|
368
|
+
"documentation": { "value": "Process and analyze text files.\n\n```bash\nawk '{print $1}' file.txt\nawk -F: '{print $1, $3}' /etc/passwd\nawk '/pattern/ {print $0}' file.txt\nawk 'NR==1 {print}' file.txt\nawk '{sum += $1} END {print sum}' data.txt\n```" },
|
|
369
|
+
"insertText": "awk '${1:{print \\$0}}' ${2:file}",
|
|
370
|
+
"insertTextRules": 4,
|
|
371
|
+
"sortText": "02_awk"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"label": "find",
|
|
375
|
+
"kind": 1,
|
|
376
|
+
"detail": "Search for files in a directory hierarchy",
|
|
377
|
+
"documentation": { "value": "Find files and directories matching criteria.\n\n```bash\nfind . -name \"*.txt\"\nfind . -type f -name \"*.log\" -mtime -7\nfind /path -size +100M\nfind . -name \"*.tmp\" -delete\nfind . -type f -exec chmod 644 {} \\;\nfind . -name \"*.py\" | xargs grep \"import\"\n```" },
|
|
378
|
+
"insertText": "find ${1:.} -name \"${2:pattern}\"",
|
|
379
|
+
"insertTextRules": 4,
|
|
380
|
+
"sortText": "02_find"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
"label": "xargs",
|
|
384
|
+
"kind": 1,
|
|
385
|
+
"detail": "Build and execute commands from stdin",
|
|
386
|
+
"documentation": { "value": "Construct argument lists and execute commands.\n\n```bash\nfind . -name \"*.txt\" | xargs grep \"pattern\"\necho \"a b c\" | xargs -n1 echo\nfind . -name \"*.bak\" -print0 | xargs -0 rm\ncat urls.txt | xargs -P 4 -I {} curl {}\n```" },
|
|
387
|
+
"insertText": "xargs ${1:command}",
|
|
388
|
+
"insertTextRules": 4,
|
|
389
|
+
"sortText": "02_xargs"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"label": "sort",
|
|
393
|
+
"kind": 1,
|
|
394
|
+
"detail": "Sort lines of text",
|
|
395
|
+
"documentation": { "value": "Sort lines in text files.\n\n```bash\nsort file.txt\nsort -n numbers.txt # numeric sort\nsort -r file.txt # reverse sort\nsort -u file.txt # unique sort\nsort -t: -k3 -n /etc/passwd\n```" },
|
|
396
|
+
"insertText": "sort ${1:file}",
|
|
397
|
+
"insertTextRules": 4,
|
|
398
|
+
"sortText": "02_sort"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"label": "uniq",
|
|
402
|
+
"kind": 1,
|
|
403
|
+
"detail": "Report or omit repeated lines",
|
|
404
|
+
"documentation": { "value": "Filter adjacent matching lines.\n\n```bash\nsort file.txt | uniq\nsort file.txt | uniq -c # count occurrences\nsort file.txt | uniq -d # only duplicates\nsort file.txt | uniq -u # only unique\n```" },
|
|
405
|
+
"insertText": "uniq ${1:file}",
|
|
406
|
+
"insertTextRules": 4,
|
|
407
|
+
"sortText": "02_uniq"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"label": "wc",
|
|
411
|
+
"kind": 1,
|
|
412
|
+
"detail": "Word, line, character, and byte count",
|
|
413
|
+
"documentation": { "value": "Count lines, words, and characters.\n\n```bash\nwc file.txt # lines, words, chars\nwc -l file.txt # line count only\nwc -w file.txt # word count only\nwc -c file.txt # byte count\nfind . -name '*.py' | wc -l\n```" },
|
|
414
|
+
"insertText": "wc -${1:l} ${2:file}",
|
|
415
|
+
"insertTextRules": 4,
|
|
416
|
+
"sortText": "02_wc"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"label": "cut",
|
|
420
|
+
"kind": 1,
|
|
421
|
+
"detail": "Remove sections from lines",
|
|
422
|
+
"documentation": { "value": "Extract columns or fields from text.\n\n```bash\ncut -d: -f1 /etc/passwd # first field, colon delim\ncut -c1-10 file.txt # characters 1-10\ncut -f2,4 -d'\\t' data.tsv # fields 2 and 4\n```" },
|
|
423
|
+
"insertText": "cut -d'${1:delimiter}' -f${2:fields} ${3:file}",
|
|
424
|
+
"insertTextRules": 4,
|
|
425
|
+
"sortText": "02_cut"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"label": "tr",
|
|
429
|
+
"kind": 1,
|
|
430
|
+
"detail": "Translate or delete characters",
|
|
431
|
+
"documentation": { "value": "Translate, squeeze, or delete characters.\n\n```bash\necho \"HELLO\" | tr 'A-Z' 'a-z' # to lowercase\necho \"hello\" | tr 'a-z' 'A-Z' # to uppercase\ntr -d '\\n' < file.txt # delete newlines\ntr -s ' ' < file.txt # squeeze spaces\n```" },
|
|
432
|
+
"insertText": "tr '${1:set1}' '${2:set2}'",
|
|
433
|
+
"insertTextRules": 4,
|
|
434
|
+
"sortText": "02_tr"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"label": "tee",
|
|
438
|
+
"kind": 1,
|
|
439
|
+
"detail": "Read from stdin and write to stdout and files",
|
|
440
|
+
"documentation": { "value": "Duplicate output to both stdout and files.\n\n```bash\ncommand | tee output.log\ncommand | tee -a output.log # append\ncommand | tee file1 file2 # multiple files\n```" },
|
|
441
|
+
"insertText": "tee ${1:file}",
|
|
442
|
+
"insertTextRules": 4,
|
|
443
|
+
"sortText": "02_tee"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"label": "head",
|
|
447
|
+
"kind": 1,
|
|
448
|
+
"detail": "Output the first part of files",
|
|
449
|
+
"documentation": { "value": "Display the first lines of a file.\n\n```bash\nhead file.txt # first 10 lines\nhead -n 20 file.txt # first 20 lines\nhead -c 100 file.txt # first 100 bytes\n```" },
|
|
450
|
+
"insertText": "head -n ${1:10} ${2:file}",
|
|
451
|
+
"insertTextRules": 4,
|
|
452
|
+
"sortText": "02_head"
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
"label": "tail",
|
|
456
|
+
"kind": 1,
|
|
457
|
+
"detail": "Output the last part of files",
|
|
458
|
+
"documentation": { "value": "Display the last lines of a file.\n\n```bash\ntail file.txt # last 10 lines\ntail -n 20 file.txt # last 20 lines\ntail -f /var/log/syslog # follow log in real time\ntail -n +5 file.txt # from line 5 onwards\n```" },
|
|
459
|
+
"insertText": "tail -n ${1:10} ${2:file}",
|
|
460
|
+
"insertTextRules": 4,
|
|
461
|
+
"sortText": "02_tail"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"label": "cat",
|
|
465
|
+
"kind": 1,
|
|
466
|
+
"detail": "Concatenate and display files",
|
|
467
|
+
"documentation": { "value": "Concatenate files and print to stdout.\n\n```bash\ncat file.txt\ncat file1.txt file2.txt > combined.txt\ncat -n file.txt # with line numbers\ncat -A file.txt # show all (tabs, EOL)\n```" },
|
|
468
|
+
"insertText": "cat ${1:file}",
|
|
469
|
+
"insertTextRules": 4,
|
|
470
|
+
"sortText": "02_cat"
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"label": "less",
|
|
474
|
+
"kind": 1,
|
|
475
|
+
"detail": "View file contents with paging",
|
|
476
|
+
"documentation": { "value": "View file contents page by page.\n\n```bash\nless file.txt\nless -N file.txt # with line numbers\nless +F /var/log/syslog # follow mode\n```" },
|
|
477
|
+
"insertText": "less ${1:file}",
|
|
478
|
+
"insertTextRules": 4,
|
|
479
|
+
"sortText": "02_less"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"label": "diff",
|
|
483
|
+
"kind": 1,
|
|
484
|
+
"detail": "Compare files line by line",
|
|
485
|
+
"documentation": { "value": "Compare files and show differences.\n\n```bash\ndiff file1.txt file2.txt\ndiff -u old.txt new.txt # unified format\ndiff -r dir1/ dir2/ # recursive compare\ndiff --color file1 file2\n```" },
|
|
486
|
+
"insertText": "diff ${1:file1} ${2:file2}",
|
|
487
|
+
"insertTextRules": 4,
|
|
488
|
+
"sortText": "02_diff"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
"label": "chmod",
|
|
492
|
+
"kind": 1,
|
|
493
|
+
"detail": "Change file permissions",
|
|
494
|
+
"documentation": { "value": "Change file mode bits.\n\n```bash\nchmod +x script.sh\nchmod 755 script.sh\nchmod -R 644 ./dir\nchmod u+rw,go-w file.txt\n```" },
|
|
495
|
+
"insertText": "chmod ${1:755} ${2:file}",
|
|
496
|
+
"insertTextRules": 4,
|
|
497
|
+
"sortText": "02_chmod"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"label": "chown",
|
|
501
|
+
"kind": 1,
|
|
502
|
+
"detail": "Change file owner and group",
|
|
503
|
+
"documentation": { "value": "Change file ownership.\n\n```bash\nchown user:group file.txt\nchown -R www-data:www-data /var/www\nchown user file.txt\n```" },
|
|
504
|
+
"insertText": "chown ${1:user}:${2:group} ${3:file}",
|
|
505
|
+
"insertTextRules": 4,
|
|
506
|
+
"sortText": "02_chown"
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
"label": "mkdir",
|
|
510
|
+
"kind": 1,
|
|
511
|
+
"detail": "Create directories",
|
|
512
|
+
"documentation": { "value": "Create one or more directories.\n\n```bash\nmkdir mydir\nmkdir -p path/to/nested/dir\nmkdir -m 755 secure_dir\n```" },
|
|
513
|
+
"insertText": "mkdir -p ${1:directory}",
|
|
514
|
+
"insertTextRules": 4,
|
|
515
|
+
"sortText": "02_mkdir"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"label": "rmdir",
|
|
519
|
+
"kind": 1,
|
|
520
|
+
"detail": "Remove empty directories",
|
|
521
|
+
"documentation": { "value": "Remove empty directories.\n\n```bash\nrmdir empty_dir\nrmdir -p path/to/empty_dirs\n```" },
|
|
522
|
+
"insertText": "rmdir ${1:directory}",
|
|
523
|
+
"insertTextRules": 4,
|
|
524
|
+
"sortText": "02_rmdir"
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
"label": "cp",
|
|
528
|
+
"kind": 1,
|
|
529
|
+
"detail": "Copy files and directories",
|
|
530
|
+
"documentation": { "value": "Copy files and directories.\n\n```bash\ncp source.txt dest.txt\ncp -r source_dir/ dest_dir/\ncp -a source/ dest/ # preserve attributes\ncp -i file.txt backup/ # interactive (prompt)\n```" },
|
|
531
|
+
"insertText": "cp ${1:source} ${2:destination}",
|
|
532
|
+
"insertTextRules": 4,
|
|
533
|
+
"sortText": "02_cp"
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"label": "mv",
|
|
537
|
+
"kind": 1,
|
|
538
|
+
"detail": "Move or rename files",
|
|
539
|
+
"documentation": { "value": "Move or rename files and directories.\n\n```bash\nmv old.txt new.txt\nmv file.txt /path/to/dest/\nmv -i source dest # interactive\nmv -n source dest # no overwrite\n```" },
|
|
540
|
+
"insertText": "mv ${1:source} ${2:destination}",
|
|
541
|
+
"insertTextRules": 4,
|
|
542
|
+
"sortText": "02_mv"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
"label": "rm",
|
|
546
|
+
"kind": 1,
|
|
547
|
+
"detail": "Remove files or directories",
|
|
548
|
+
"documentation": { "value": "Remove files or directories.\n\n```bash\nrm file.txt\nrm -f file.txt # force, no prompt\nrm -r directory/ # recursive\nrm -rf directory/ # force recursive\nrm -i file.txt # interactive\n```" },
|
|
549
|
+
"insertText": "rm ${1:file}",
|
|
550
|
+
"insertTextRules": 4,
|
|
551
|
+
"sortText": "02_rm"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
"label": "ln",
|
|
555
|
+
"kind": 1,
|
|
556
|
+
"detail": "Create links between files",
|
|
557
|
+
"documentation": { "value": "Create hard and symbolic links.\n\n```bash\nln -s /path/to/target link_name # symbolic link\nln target link_name # hard link\nln -sf /new/target link_name # force symbolic\n```" },
|
|
558
|
+
"insertText": "ln -s ${1:target} ${2:link_name}",
|
|
559
|
+
"insertTextRules": 4,
|
|
560
|
+
"sortText": "02_ln"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"label": "touch",
|
|
564
|
+
"kind": 1,
|
|
565
|
+
"detail": "Create file or update timestamps",
|
|
566
|
+
"documentation": { "value": "Create an empty file or update file timestamps.\n\n```bash\ntouch newfile.txt\ntouch -t 202301010000 file.txt # set specific time\ntouch -r ref_file target_file # copy timestamp\n```" },
|
|
567
|
+
"insertText": "touch ${1:file}",
|
|
568
|
+
"insertTextRules": 4,
|
|
569
|
+
"sortText": "02_touch"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"label": "tar",
|
|
573
|
+
"kind": 1,
|
|
574
|
+
"detail": "Archive files",
|
|
575
|
+
"documentation": { "value": "Create and extract archive files.\n\n```bash\ntar czf archive.tar.gz dir/ # create gzipped\ntar xzf archive.tar.gz # extract gzipped\ntar xjf archive.tar.bz2 # extract bzip2\ntar tf archive.tar # list contents\ntar czf backup.tar.gz --exclude='*.log' dir/\n```" },
|
|
576
|
+
"insertText": "tar ${1:czf} ${2:archive.tar.gz} ${3:directory}",
|
|
577
|
+
"insertTextRules": 4,
|
|
578
|
+
"sortText": "02_tar"
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
"label": "gzip",
|
|
582
|
+
"kind": 1,
|
|
583
|
+
"detail": "Compress or decompress files",
|
|
584
|
+
"documentation": { "value": "Compress or expand files.\n\n```bash\ngzip file.txt # compress (replaces file)\ngzip -d file.txt.gz # decompress\ngzip -k file.txt # keep original\ngzip -9 file.txt # max compression\n```" },
|
|
585
|
+
"insertText": "gzip ${1:file}",
|
|
586
|
+
"insertTextRules": 4,
|
|
587
|
+
"sortText": "02_gzip"
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
"label": "curl",
|
|
591
|
+
"kind": 1,
|
|
592
|
+
"detail": "Transfer data from or to a server",
|
|
593
|
+
"documentation": { "value": "Make HTTP requests and transfer data.\n\n```bash\ncurl https://example.com\ncurl -o file.txt https://example.com/file\ncurl -X POST -d '{\"key\":\"val\"}' -H 'Content-Type: application/json' url\ncurl -sS https://example.com | jq .\ncurl -L -O https://example.com/download.tar.gz\n```" },
|
|
594
|
+
"insertText": "curl ${1:-sS} ${2:url}",
|
|
595
|
+
"insertTextRules": 4,
|
|
596
|
+
"sortText": "02_curl"
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
"label": "wget",
|
|
600
|
+
"kind": 1,
|
|
601
|
+
"detail": "Download files from the web",
|
|
602
|
+
"documentation": { "value": "Non-interactive network downloader.\n\n```bash\nwget https://example.com/file.tar.gz\nwget -O output.html https://example.com\nwget -q -O- https://example.com\nwget -r -np https://example.com/dir/\n```" },
|
|
603
|
+
"insertText": "wget ${1:url}",
|
|
604
|
+
"insertTextRules": 4,
|
|
605
|
+
"sortText": "02_wget"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"label": "test",
|
|
609
|
+
"kind": 1,
|
|
610
|
+
"detail": "Evaluate conditional expression",
|
|
611
|
+
"documentation": { "value": "Evaluate conditional expressions. Usually used as `[` or `[[`.\n\n```bash\ntest -f file.txt && echo \"exists\"\n[ -d /path ] && echo \"is directory\"\n[[ -z \"$var\" ]] && echo \"empty\"\n[[ \"$a\" == \"$b\" ]] && echo \"equal\"\n```" },
|
|
612
|
+
"insertText": "test ${1:expression}",
|
|
613
|
+
"insertTextRules": 4,
|
|
614
|
+
"sortText": "00_test"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
"label": "[[ -f file ]]",
|
|
618
|
+
"kind": 15,
|
|
619
|
+
"detail": "Test if file exists and is regular file",
|
|
620
|
+
"documentation": { "value": "Conditional test operators:\n\n```bash\n[[ -f file ]] # file exists and is regular file\n[[ -d dir ]] # directory exists\n[[ -e path ]] # path exists (any type)\n[[ -r file ]] # file is readable\n[[ -w file ]] # file is writable\n[[ -x file ]] # file is executable\n[[ -s file ]] # file exists and is non-empty\n[[ -L file ]] # file is symbolic link\n```" },
|
|
621
|
+
"insertText": "[[ -f \"${1:file}\" ]]",
|
|
622
|
+
"insertTextRules": 4,
|
|
623
|
+
"sortText": "03_test_f"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"label": "[[ -d dir ]]",
|
|
627
|
+
"kind": 15,
|
|
628
|
+
"detail": "Test if directory exists",
|
|
629
|
+
"documentation": { "value": "Test if path is a directory.\n\n```bash\nif [[ -d \"$dir\" ]]; then\n echo \"Directory exists\"\nfi\n```" },
|
|
630
|
+
"insertText": "[[ -d \"${1:directory}\" ]]",
|
|
631
|
+
"insertTextRules": 4,
|
|
632
|
+
"sortText": "03_test_d"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"label": "[[ -e path ]]",
|
|
636
|
+
"kind": 15,
|
|
637
|
+
"detail": "Test if path exists",
|
|
638
|
+
"documentation": { "value": "Test if a file or directory exists.\n\n```bash\nif [[ -e \"$path\" ]]; then\n echo \"Path exists\"\nfi\n```" },
|
|
639
|
+
"insertText": "[[ -e \"${1:path}\" ]]",
|
|
640
|
+
"insertTextRules": 4,
|
|
641
|
+
"sortText": "03_test_e"
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
"label": "[[ -z string ]]",
|
|
645
|
+
"kind": 15,
|
|
646
|
+
"detail": "Test if string is empty",
|
|
647
|
+
"documentation": { "value": "Test if a string has zero length.\n\n```bash\nif [[ -z \"$var\" ]]; then\n echo \"Variable is empty\"\nfi\n```" },
|
|
648
|
+
"insertText": "[[ -z \"${1:string}\" ]]",
|
|
649
|
+
"insertTextRules": 4,
|
|
650
|
+
"sortText": "03_test_z"
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"label": "[[ -n string ]]",
|
|
654
|
+
"kind": 15,
|
|
655
|
+
"detail": "Test if string is non-empty",
|
|
656
|
+
"documentation": { "value": "Test if a string has non-zero length.\n\n```bash\nif [[ -n \"$var\" ]]; then\n echo \"Variable is not empty\"\nfi\n```" },
|
|
657
|
+
"insertText": "[[ -n \"${1:string}\" ]]",
|
|
658
|
+
"insertTextRules": 4,
|
|
659
|
+
"sortText": "03_test_n"
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
"label": "[[ a -eq b ]]",
|
|
663
|
+
"kind": 15,
|
|
664
|
+
"detail": "Integer comparison operators",
|
|
665
|
+
"documentation": { "value": "Integer comparison operators:\n\n```bash\n[[ $a -eq $b ]] # equal\n[[ $a -ne $b ]] # not equal\n[[ $a -gt $b ]] # greater than\n[[ $a -lt $b ]] # less than\n[[ $a -ge $b ]] # greater or equal\n[[ $a -le $b ]] # less or equal\n```" },
|
|
666
|
+
"insertText": "[[ ${1:a} -${2:eq} ${3:b} ]]",
|
|
667
|
+
"insertTextRules": 4,
|
|
668
|
+
"sortText": "03_test_eq"
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"label": "${var:-default}",
|
|
672
|
+
"kind": 5,
|
|
673
|
+
"detail": "Variable with default value",
|
|
674
|
+
"documentation": { "value": "Use default value if variable is unset or null.\n\n```bash\nname=${name:-\"World\"}\necho \"Hello, ${user:-guest}\"\n```" },
|
|
675
|
+
"insertText": "${${1:var}:-${2:default}}",
|
|
676
|
+
"insertTextRules": 4,
|
|
677
|
+
"sortText": "04_var_default"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"label": "${var:+alternate}",
|
|
681
|
+
"kind": 5,
|
|
682
|
+
"detail": "Variable with alternate value",
|
|
683
|
+
"documentation": { "value": "Use alternate value if variable IS set and non-null.\n\n```bash\nresult=${var:+\"var is set\"}\nflags=\"${verbose:+-v}\"\n```" },
|
|
684
|
+
"insertText": "${${1:var}:+${2:alternate}}",
|
|
685
|
+
"insertTextRules": 4,
|
|
686
|
+
"sortText": "04_var_alternate"
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"label": "${var:=default}",
|
|
690
|
+
"kind": 5,
|
|
691
|
+
"detail": "Assign default if unset",
|
|
692
|
+
"documentation": { "value": "Assign default value if variable is unset or null.\n\n```bash\n: ${CONFIG_DIR:=/etc/myapp}\necho ${name:=\"Anonymous\"}\n```" },
|
|
693
|
+
"insertText": "${${1:var}:=${2:default}}",
|
|
694
|
+
"insertTextRules": 4,
|
|
695
|
+
"sortText": "04_var_assign_default"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
"label": "${var:?error}",
|
|
699
|
+
"kind": 5,
|
|
700
|
+
"detail": "Error if variable unset",
|
|
701
|
+
"documentation": { "value": "Display error and exit if variable is unset or null.\n\n```bash\n: ${HOME:?\"HOME is not set\"}\nfile=${1:?\"Usage: $0 <filename>\"}\n```" },
|
|
702
|
+
"insertText": "${${1:var}:?${2:error message}}",
|
|
703
|
+
"insertTextRules": 4,
|
|
704
|
+
"sortText": "04_var_error"
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
"label": "${#var}",
|
|
708
|
+
"kind": 5,
|
|
709
|
+
"detail": "String length",
|
|
710
|
+
"documentation": { "value": "Get the length of a string variable.\n\n```bash\nstr=\"Hello\"\necho ${#str} # 5\necho ${#arr[@]} # array length\n```" },
|
|
711
|
+
"insertText": "${#${1:var}}",
|
|
712
|
+
"insertTextRules": 4,
|
|
713
|
+
"sortText": "04_var_length"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
"label": "${var%pattern}",
|
|
717
|
+
"kind": 5,
|
|
718
|
+
"detail": "Remove shortest suffix match",
|
|
719
|
+
"documentation": { "value": "Remove shortest trailing pattern match.\n\n```bash\npath=\"/home/user/file.txt\"\necho ${path%/*} # /home/user\necho ${path%.txt} # /home/user/file\n```" },
|
|
720
|
+
"insertText": "${${1:var}%${2:pattern}}",
|
|
721
|
+
"insertTextRules": 4,
|
|
722
|
+
"sortText": "04_var_suffix_short"
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
"label": "${var%%pattern}",
|
|
726
|
+
"kind": 5,
|
|
727
|
+
"detail": "Remove longest suffix match",
|
|
728
|
+
"documentation": { "value": "Remove longest trailing pattern match.\n\n```bash\npath=\"dir1/dir2/file.tar.gz\"\necho ${path%%/*} # dir1\necho ${path%%.*} # dir1/dir2/file\n```" },
|
|
729
|
+
"insertText": "${${1:var}%%${2:pattern}}",
|
|
730
|
+
"insertTextRules": 4,
|
|
731
|
+
"sortText": "04_var_suffix_long"
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
"label": "${var#pattern}",
|
|
735
|
+
"kind": 5,
|
|
736
|
+
"detail": "Remove shortest prefix match",
|
|
737
|
+
"documentation": { "value": "Remove shortest leading pattern match.\n\n```bash\npath=\"/home/user/file.txt\"\necho ${path#*/} # home/user/file.txt\n```" },
|
|
738
|
+
"insertText": "${${1:var}#${2:pattern}}",
|
|
739
|
+
"insertTextRules": 4,
|
|
740
|
+
"sortText": "04_var_prefix_short"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
"label": "${var##pattern}",
|
|
744
|
+
"kind": 5,
|
|
745
|
+
"detail": "Remove longest prefix match",
|
|
746
|
+
"documentation": { "value": "Remove longest leading pattern match.\n\n```bash\npath=\"/home/user/file.txt\"\necho ${path##*/} # file.txt\n```" },
|
|
747
|
+
"insertText": "${${1:var}##${2:pattern}}",
|
|
748
|
+
"insertTextRules": 4,
|
|
749
|
+
"sortText": "04_var_prefix_long"
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
"label": "${var/pattern/replacement}",
|
|
753
|
+
"kind": 5,
|
|
754
|
+
"detail": "Pattern substitution (first match)",
|
|
755
|
+
"documentation": { "value": "Replace first match of pattern.\n\n```bash\nstr=\"hello world hello\"\necho ${str/hello/Hi} # Hi world hello\n```" },
|
|
756
|
+
"insertText": "${${1:var}/${2:pattern}/${3:replacement}}",
|
|
757
|
+
"insertTextRules": 4,
|
|
758
|
+
"sortText": "04_var_replace"
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
"label": "${var//pattern/replacement}",
|
|
762
|
+
"kind": 5,
|
|
763
|
+
"detail": "Pattern substitution (all matches)",
|
|
764
|
+
"documentation": { "value": "Replace all matches of pattern.\n\n```bash\nstr=\"hello world hello\"\necho ${str//hello/Hi} # Hi world Hi\n```" },
|
|
765
|
+
"insertText": "${${1:var}//${2:pattern}/${3:replacement}}",
|
|
766
|
+
"insertTextRules": 4,
|
|
767
|
+
"sortText": "04_var_replace_all"
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
"label": "${var:offset:length}",
|
|
771
|
+
"kind": 5,
|
|
772
|
+
"detail": "Substring extraction",
|
|
773
|
+
"documentation": { "value": "Extract a substring.\n\n```bash\nstr=\"Hello World\"\necho ${str:0:5} # Hello\necho ${str:6} # World\necho ${str: -5} # World (note the space)\n```" },
|
|
774
|
+
"insertText": "${${1:var}:${2:offset}:${3:length}}",
|
|
775
|
+
"insertTextRules": 4,
|
|
776
|
+
"sortText": "04_var_substring"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
"label": "${var^}",
|
|
780
|
+
"kind": 5,
|
|
781
|
+
"detail": "Uppercase first character",
|
|
782
|
+
"documentation": { "value": "Convert first character to uppercase.\n\n```bash\nname=\"alice\"\necho ${name^} # Alice\necho ${name^^} # ALICE (all uppercase)\n```" },
|
|
783
|
+
"insertText": "${${1:var}^}",
|
|
784
|
+
"insertTextRules": 4,
|
|
785
|
+
"sortText": "04_var_upper"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
"label": "${var,}",
|
|
789
|
+
"kind": 5,
|
|
790
|
+
"detail": "Lowercase first character",
|
|
791
|
+
"documentation": { "value": "Convert first character to lowercase.\n\n```bash\nname=\"ALICE\"\necho ${name,} # aLICE\necho ${name,,} # alice (all lowercase)\n```" },
|
|
792
|
+
"insertText": "${${1:var},}",
|
|
793
|
+
"insertTextRules": 4,
|
|
794
|
+
"sortText": "04_var_lower"
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
"label": "if-then-fi",
|
|
798
|
+
"kind": 27,
|
|
799
|
+
"detail": "If-then-fi block (snippet)",
|
|
800
|
+
"documentation": { "value": "Complete if-then-fi conditional block.\n\n```bash\nif [[ condition ]]; then\n commands\nfi\n```" },
|
|
801
|
+
"insertText": "if [[ ${1:condition} ]]; then\n\t${2:# commands}\nfi",
|
|
802
|
+
"insertTextRules": 4,
|
|
803
|
+
"sortText": "05_snip_if"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
"label": "if-then-else-fi",
|
|
807
|
+
"kind": 27,
|
|
808
|
+
"detail": "If-then-else-fi block (snippet)",
|
|
809
|
+
"documentation": { "value": "Complete if-then-else-fi block.\n\n```bash\nif [[ condition ]]; then\n commands\nelse\n other_commands\nfi\n```" },
|
|
810
|
+
"insertText": "if [[ ${1:condition} ]]; then\n\t${2:# true branch}\nelse\n\t${3:# false branch}\nfi",
|
|
811
|
+
"insertTextRules": 4,
|
|
812
|
+
"sortText": "05_snip_if_else"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
"label": "for-in-do-done",
|
|
816
|
+
"kind": 27,
|
|
817
|
+
"detail": "For-in loop (snippet)",
|
|
818
|
+
"documentation": { "value": "For-in loop over a list.\n\n```bash\nfor item in \"${array[@]}\"; do\n echo \"$item\"\ndone\n```" },
|
|
819
|
+
"insertText": "for ${1:item} in ${2:\"$\\{list[@]\\}\"}; do\n\t${3:echo \"\\$${1:item}\"}\ndone",
|
|
820
|
+
"insertTextRules": 4,
|
|
821
|
+
"sortText": "05_snip_for_in"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"label": "for-c-style",
|
|
825
|
+
"kind": 27,
|
|
826
|
+
"detail": "C-style for loop (snippet)",
|
|
827
|
+
"documentation": { "value": "C-style for loop.\n\n```bash\nfor ((i=0; i<10; i++)); do\n echo \"$i\"\ndone\n```" },
|
|
828
|
+
"insertText": "for ((${1:i}=${2:0}; ${1:i}<${3:10}; ${1:i}++)); do\n\t${4:echo \"\\$${1:i}\"}\ndone",
|
|
829
|
+
"insertTextRules": 4,
|
|
830
|
+
"sortText": "05_snip_for_c"
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
"label": "while-read-loop",
|
|
834
|
+
"kind": 27,
|
|
835
|
+
"detail": "While-read loop (snippet)",
|
|
836
|
+
"documentation": { "value": "Read a file line by line.\n\n```bash\nwhile IFS= read -r line; do\n echo \"$line\"\ndone < file.txt\n```" },
|
|
837
|
+
"insertText": "while IFS= read -r ${1:line}; do\n\t${2:echo \"\\$${1:line}\"}\ndone < ${3:file.txt}",
|
|
838
|
+
"insertTextRules": 4,
|
|
839
|
+
"sortText": "05_snip_while_read"
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
"label": "while-true-loop",
|
|
843
|
+
"kind": 27,
|
|
844
|
+
"detail": "Infinite while loop (snippet)",
|
|
845
|
+
"documentation": { "value": "Infinite loop until break.\n\n```bash\nwhile true; do\n commands\n [[ condition ]] && break\ndone\n```" },
|
|
846
|
+
"insertText": "while true; do\n\t${1:# commands}\n\t${2:break}\ndone",
|
|
847
|
+
"insertTextRules": 4,
|
|
848
|
+
"sortText": "05_snip_while_true"
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
"label": "case-esac",
|
|
852
|
+
"kind": 27,
|
|
853
|
+
"detail": "Case statement (snippet)",
|
|
854
|
+
"documentation": { "value": "Pattern matching case statement.\n\n```bash\ncase \"$var\" in\n pattern1) commands ;;\n pattern2) commands ;;\n *) default ;;\nesac\n```" },
|
|
855
|
+
"insertText": "case \"${1:\\$variable}\" in\n\t${2:pattern1})\n\t\t${3:commands}\n\t\t;;\n\t${4:pattern2})\n\t\t${5:commands}\n\t\t;;\n\t*)\n\t\t${6:echo \"Unknown option\"}\n\t\t;;\nesac",
|
|
856
|
+
"insertTextRules": 4,
|
|
857
|
+
"sortText": "05_snip_case"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
"label": "function-def",
|
|
861
|
+
"kind": 27,
|
|
862
|
+
"detail": "Function definition (snippet)",
|
|
863
|
+
"documentation": { "value": "Define a new shell function.\n\n```bash\nmy_function() {\n local arg1=\"$1\"\n # function body\n}\n```" },
|
|
864
|
+
"insertText": "${1:function_name}() {\n\tlocal ${2:arg}=\"\\$1\"\n\t${3:# function body}\n}",
|
|
865
|
+
"insertTextRules": 4,
|
|
866
|
+
"sortText": "05_snip_function"
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
"label": "#!/bin/bash",
|
|
870
|
+
"kind": 27,
|
|
871
|
+
"detail": "Bash shebang (snippet)",
|
|
872
|
+
"documentation": { "value": "Shebang line for a bash script with strict mode.\n\n```bash\n#!/bin/bash\nset -euo pipefail\n```" },
|
|
873
|
+
"insertText": "#!/bin/bash\nset -euo pipefail\nIFS=$$'\\n\\t'\n\n${1:# Script starts here}",
|
|
874
|
+
"insertTextRules": 4,
|
|
875
|
+
"sortText": "05_snip_shebang"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
"label": "#!/usr/bin/env bash",
|
|
879
|
+
"kind": 27,
|
|
880
|
+
"detail": "Portable bash shebang (snippet)",
|
|
881
|
+
"documentation": { "value": "Portable shebang line using env to find bash.\n\n```bash\n#!/usr/bin/env bash\nset -euo pipefail\n```" },
|
|
882
|
+
"insertText": "#!/usr/bin/env bash\nset -euo pipefail\n\n${1:# Script starts here}",
|
|
883
|
+
"insertTextRules": 4,
|
|
884
|
+
"sortText": "05_snip_shebang_env"
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"label": "heredoc",
|
|
888
|
+
"kind": 27,
|
|
889
|
+
"detail": "Here document (snippet)",
|
|
890
|
+
"documentation": { "value": "Multi-line string using a here document.\n\n```bash\ncat <<EOF\nHello, $USER.\nToday is $(date).\nEOF\n\ncat <<'EOF' # no variable expansion\n$literal \\text\nEOF\n```" },
|
|
891
|
+
"insertText": "cat <<${1:EOF}\n${2:content}\n${1:EOF}",
|
|
892
|
+
"insertTextRules": 4,
|
|
893
|
+
"sortText": "05_snip_heredoc"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"label": "herestring",
|
|
897
|
+
"kind": 27,
|
|
898
|
+
"detail": "Here string (snippet)",
|
|
899
|
+
"documentation": { "value": "Feed a string to a command's stdin.\n\n```bash\nread -r first rest <<< \"Hello World\"\ngrep \"pattern\" <<< \"$string_var\"\n```" },
|
|
900
|
+
"insertText": "<<< \"${1:string}\"",
|
|
901
|
+
"insertTextRules": 4,
|
|
902
|
+
"sortText": "05_snip_herestring"
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
"label": "trap-cleanup",
|
|
906
|
+
"kind": 27,
|
|
907
|
+
"detail": "Trap cleanup on exit (snippet)",
|
|
908
|
+
"documentation": { "value": "Set up a cleanup function that runs on script exit.\n\n```bash\ncleanup() {\n rm -rf \"$tmpdir\"\n}\ntrap cleanup EXIT\n```" },
|
|
909
|
+
"insertText": "cleanup() {\n\t${1:rm -rf \"\\$tmpdir\"}\n}\ntrap cleanup EXIT",
|
|
910
|
+
"insertTextRules": 4,
|
|
911
|
+
"sortText": "05_snip_trap_cleanup"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
"label": "getopts-loop",
|
|
915
|
+
"kind": 27,
|
|
916
|
+
"detail": "Parse options with getopts (snippet)",
|
|
917
|
+
"documentation": { "value": "Parse command-line options.\n\n```bash\nwhile getopts \":hv:f:\" opt; do\n case $opt in\n h) usage ;;\n v) verbose=1 ;;\n f) file=\"$OPTARG\" ;;\n \\?) echo \"Invalid: -$OPTARG\" ;;\n :) echo \"Missing arg: -$OPTARG\" ;;\n esac\ndone\nshift $((OPTIND - 1))\n```" },
|
|
918
|
+
"insertText": "while getopts \":${1:hv:f:}\" opt; do\n\tcase \\$opt in\n\t\t${2:h}) ${3:usage} ;;\n\t\t${4:v}) ${5:verbose=1} ;;\n\t\t${6:f}) ${7:file=\"\\$OPTARG\"} ;;\n\t\t\\\\?) echo \"Invalid option: -\\$OPTARG\" >&2; exit 1 ;;\n\t\t:) echo \"Option -\\$OPTARG requires an argument\" >&2; exit 1 ;;\n\tesac\ndone\nshift \\$((OPTIND - 1))",
|
|
919
|
+
"insertTextRules": 4,
|
|
920
|
+
"sortText": "05_snip_getopts"
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
"label": "array-iterate",
|
|
924
|
+
"kind": 27,
|
|
925
|
+
"detail": "Iterate over array (snippet)",
|
|
926
|
+
"documentation": { "value": "Loop over all elements of an array.\n\n```bash\nfor item in \"${array[@]}\"; do\n echo \"$item\"\ndone\n```" },
|
|
927
|
+
"insertText": "for ${1:item} in \"${${2:array}[@]}\"; do\n\techo \"\\$${1:item}\"\ndone",
|
|
928
|
+
"insertTextRules": 4,
|
|
929
|
+
"sortText": "05_snip_array_iter"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"label": "pipe-while",
|
|
933
|
+
"kind": 27,
|
|
934
|
+
"detail": "Process command output line by line (snippet)",
|
|
935
|
+
"documentation": { "value": "Pipe command output to a while-read loop.\n\n```bash\ncommand | while IFS= read -r line; do\n echo \"$line\"\ndone\n```" },
|
|
936
|
+
"insertText": "${1:command} | while IFS= read -r ${2:line}; do\n\techo \"\\$${2:line}\"\ndone",
|
|
937
|
+
"insertTextRules": 4,
|
|
938
|
+
"sortText": "05_snip_pipe_while"
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
"label": "process-substitution",
|
|
942
|
+
"kind": 27,
|
|
943
|
+
"detail": "Process substitution (snippet)",
|
|
944
|
+
"documentation": { "value": "Use command output as a file.\n\n```bash\ndiff <(command1) <(command2)\nwhile read -r line; do\n echo \"$line\"\ndone < <(command)\n```" },
|
|
945
|
+
"insertText": "<(${1:command})",
|
|
946
|
+
"insertTextRules": 4,
|
|
947
|
+
"sortText": "05_snip_proc_sub"
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
"label": "command-substitution",
|
|
951
|
+
"kind": 27,
|
|
952
|
+
"detail": "Command substitution (snippet)",
|
|
953
|
+
"documentation": { "value": "Capture command output into a variable.\n\n```bash\nresult=$(command arg1 arg2)\ntoday=$(date +%Y-%m-%d)\ncount=$(wc -l < file.txt)\n```" },
|
|
954
|
+
"insertText": "$(${1:command})",
|
|
955
|
+
"insertTextRules": 4,
|
|
956
|
+
"sortText": "05_snip_cmd_sub"
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
"label": "arithmetic",
|
|
960
|
+
"kind": 27,
|
|
961
|
+
"detail": "Arithmetic expression (snippet)",
|
|
962
|
+
"documentation": { "value": "Perform arithmetic.\n\n```bash\n((count++))\n((result = a + b))\nif ((x > 10)); then echo \"big\"; fi\nresult=$((a * b + c))\n```" },
|
|
963
|
+
"insertText": "$((${1:expression}))",
|
|
964
|
+
"insertTextRules": 4,
|
|
965
|
+
"sortText": "05_snip_arithmetic"
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
"label": "tempfile",
|
|
969
|
+
"kind": 27,
|
|
970
|
+
"detail": "Create temporary file (snippet)",
|
|
971
|
+
"documentation": { "value": "Safely create and clean up a temporary file.\n\n```bash\ntmpfile=$(mktemp)\ntrap 'rm -f \"$tmpfile\"' EXIT\n```" },
|
|
972
|
+
"insertText": "${1:tmpfile}=$(mktemp)\ntrap 'rm -f \"\\$${1:tmpfile}\"' EXIT",
|
|
973
|
+
"insertTextRules": 4,
|
|
974
|
+
"sortText": "05_snip_tempfile"
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
"label": "tempdir",
|
|
978
|
+
"kind": 27,
|
|
979
|
+
"detail": "Create temporary directory (snippet)",
|
|
980
|
+
"documentation": { "value": "Safely create and clean up a temporary directory.\n\n```bash\ntmpdir=$(mktemp -d)\ntrap 'rm -rf \"$tmpdir\"' EXIT\n```" },
|
|
981
|
+
"insertText": "${1:tmpdir}=$(mktemp -d)\ntrap 'rm -rf \"\\$${1:tmpdir}\"' EXIT",
|
|
982
|
+
"insertTextRules": 4,
|
|
983
|
+
"sortText": "05_snip_tempdir"
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
"label": "check-command-exists",
|
|
987
|
+
"kind": 27,
|
|
988
|
+
"detail": "Check if command exists (snippet)",
|
|
989
|
+
"documentation": { "value": "Verify a command is available before using it.\n\n```bash\nif ! command -v docker &> /dev/null; then\n echo \"docker not found\"\n exit 1\nfi\n```" },
|
|
990
|
+
"insertText": "if ! command -v ${1:command} &> /dev/null; then\n\techo \"${1:command} is not installed\" >&2\n\texit 1\nfi",
|
|
991
|
+
"insertTextRules": 4,
|
|
992
|
+
"sortText": "05_snip_check_cmd"
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
"label": "error-handling",
|
|
996
|
+
"kind": 27,
|
|
997
|
+
"detail": "Error handling function (snippet)",
|
|
998
|
+
"documentation": { "value": "Define an error handler with line number reporting.\n\n```bash\ndie() {\n echo \"Error: $*\" >&2\n exit 1\n}\n```" },
|
|
999
|
+
"insertText": "die() {\n\techo \"Error: \\$*\" >&2\n\texit 1\n}",
|
|
1000
|
+
"insertTextRules": 4,
|
|
1001
|
+
"sortText": "05_snip_error_handling"
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
"label": "logging",
|
|
1005
|
+
"kind": 27,
|
|
1006
|
+
"detail": "Logging functions (snippet)",
|
|
1007
|
+
"documentation": { "value": "Simple logging functions.\n\n```bash\nlog() { echo \"[$(date +'%Y-%m-%d %H:%M:%S')] $*\"; }\nwarn() { log \"WARN: $*\" >&2; }\nerr() { log \"ERROR: $*\" >&2; }\n```" },
|
|
1008
|
+
"insertText": "log() { echo \"[\\$(date +'%Y-%m-%d %H:%M:%S')] \\$*\"; }\nwarn() { log \"WARN: \\$*\" >&2; }\nerr() { log \"ERROR: \\$*\" >&2; }",
|
|
1009
|
+
"insertTextRules": 4,
|
|
1010
|
+
"sortText": "05_snip_logging"
|
|
1011
|
+
},
|
|
1012
|
+
{
|
|
1013
|
+
"label": "script-dir",
|
|
1014
|
+
"kind": 27,
|
|
1015
|
+
"detail": "Get script directory (snippet)",
|
|
1016
|
+
"documentation": { "value": "Reliably get the directory of the current script.\n\n```bash\nSCRIPT_DIR=\"$(cd \"$(dirname \"${BASH_SOURCE[0]}\")\" && pwd)\"\n```" },
|
|
1017
|
+
"insertText": "SCRIPT_DIR=\"\\$(cd \"\\$(dirname \"\\${BASH_SOURCE[0]}\")\" && pwd)\"",
|
|
1018
|
+
"insertTextRules": 4,
|
|
1019
|
+
"sortText": "05_snip_script_dir"
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
"label": "confirm-prompt",
|
|
1023
|
+
"kind": 27,
|
|
1024
|
+
"detail": "Confirmation prompt (snippet)",
|
|
1025
|
+
"documentation": { "value": "Ask for user confirmation.\n\n```bash\nread -rp \"Are you sure? [y/N] \" ans\n[[ \"$ans\" =~ ^[Yy] ]] || exit 0\n```" },
|
|
1026
|
+
"insertText": "read -rp \"${1:Are you sure?} [y/N] \" ans\n[[ \"\\$ans\" =~ ^[Yy] ]] || exit 0",
|
|
1027
|
+
"insertTextRules": 4,
|
|
1028
|
+
"sortText": "05_snip_confirm"
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
"label": "retry-loop",
|
|
1032
|
+
"kind": 27,
|
|
1033
|
+
"detail": "Retry a command (snippet)",
|
|
1034
|
+
"documentation": { "value": "Retry a command with exponential backoff.\n\n```bash\nretry() {\n local max=5 delay=1 i\n for ((i=1; i<=max; i++)); do\n \"$@\" && return 0\n sleep $delay\n ((delay *= 2))\n done\n return 1\n}\n```" },
|
|
1035
|
+
"insertText": "retry() {\n\tlocal max=${1:5} delay=1 i\n\tfor ((i=1; i<=max; i++)); do\n\t\t\"\\$@\" && return 0\n\t\techo \"Attempt \\$i/\\$max failed. Retrying in \\${delay}s...\" >&2\n\t\tsleep \\$delay\n\t\t((delay *= 2))\n\tdone\n\treturn 1\n}",
|
|
1036
|
+
"insertTextRules": 4,
|
|
1037
|
+
"sortText": "05_snip_retry"
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
"label": "parallel-jobs",
|
|
1041
|
+
"kind": 27,
|
|
1042
|
+
"detail": "Run parallel background jobs (snippet)",
|
|
1043
|
+
"documentation": { "value": "Run commands in parallel and wait for all.\n\n```bash\npids=()\nfor item in \"${items[@]}\"; do\n process \"$item\" &\n pids+=(\"$!\")\ndone\nfor pid in \"${pids[@]}\"; do\n wait \"$pid\"\ndone\n```" },
|
|
1044
|
+
"insertText": "pids=()\nfor ${1:item} in \"${${2:items}[@]}\"; do\n\t${3:process} \"\\$${1:item}\" &\n\tpids+=(\"\\$!\")\ndone\nfor pid in \"\\${pids[@]}\"; do\n\twait \"\\$pid\"\ndone",
|
|
1045
|
+
"insertTextRules": 4,
|
|
1046
|
+
"sortText": "05_snip_parallel"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
"label": "basename",
|
|
1050
|
+
"kind": 1,
|
|
1051
|
+
"detail": "Strip directory from filename",
|
|
1052
|
+
"documentation": { "value": "Return the filename portion of a path.\n\n```bash\nbasename /path/to/file.txt # file.txt\nbasename /path/to/file.txt .txt # file\nbasename -a /path/a /path/b # a b\n```" },
|
|
1053
|
+
"insertText": "basename ${1:path}",
|
|
1054
|
+
"insertTextRules": 4,
|
|
1055
|
+
"sortText": "02_basename"
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
"label": "dirname",
|
|
1059
|
+
"kind": 1,
|
|
1060
|
+
"detail": "Strip filename from path",
|
|
1061
|
+
"documentation": { "value": "Return the directory portion of a path.\n\n```bash\ndirname /path/to/file.txt # /path/to\ndirname ./file.txt # .\n```" },
|
|
1062
|
+
"insertText": "dirname ${1:path}",
|
|
1063
|
+
"insertTextRules": 4,
|
|
1064
|
+
"sortText": "02_dirname"
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
"label": "date",
|
|
1068
|
+
"kind": 1,
|
|
1069
|
+
"detail": "Display or set date and time",
|
|
1070
|
+
"documentation": { "value": "Display the current date/time or convert date formats.\n\n```bash\ndate\ndate +\"%Y-%m-%d %H:%M:%S\"\ndate -d \"yesterday\" +%Y-%m-%d\ndate -u # UTC time\n```" },
|
|
1071
|
+
"insertText": "date +\"${1:%Y-%m-%d %H:%M:%S}\"",
|
|
1072
|
+
"insertTextRules": 4,
|
|
1073
|
+
"sortText": "02_date"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
"label": "sleep",
|
|
1077
|
+
"kind": 1,
|
|
1078
|
+
"detail": "Delay for a specified time",
|
|
1079
|
+
"documentation": { "value": "Pause execution for a specified duration.\n\n```bash\nsleep 5 # 5 seconds\nsleep 0.5 # half second\nsleep 1m # 1 minute\nsleep 1h # 1 hour\n```" },
|
|
1080
|
+
"insertText": "sleep ${1:1}",
|
|
1081
|
+
"insertTextRules": 4,
|
|
1082
|
+
"sortText": "02_sleep"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
"label": "mktemp",
|
|
1086
|
+
"kind": 1,
|
|
1087
|
+
"detail": "Create temporary file or directory",
|
|
1088
|
+
"documentation": { "value": "Safely create a temporary file or directory.\n\n```bash\ntmpfile=$(mktemp)\ntmpdir=$(mktemp -d)\nmktemp /tmp/myapp.XXXXXX\n```" },
|
|
1089
|
+
"insertText": "mktemp ${1:-d}",
|
|
1090
|
+
"insertTextRules": 4,
|
|
1091
|
+
"sortText": "02_mktemp"
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
"label": "xargs",
|
|
1095
|
+
"kind": 1,
|
|
1096
|
+
"detail": "Build and execute commands from stdin",
|
|
1097
|
+
"documentation": { "value": "Construct argument lists and invoke commands.\n\n```bash\nfind . -name '*.txt' | xargs wc -l\necho '1 2 3' | xargs -n1 echo\nfind . -print0 | xargs -0 rm\ncat list.txt | xargs -I {} cp {} /dest/\n```" },
|
|
1098
|
+
"insertText": "xargs ${1:-I {}} ${2:command}",
|
|
1099
|
+
"insertTextRules": 4,
|
|
1100
|
+
"sortText": "02_xargs2"
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
"label": "wait",
|
|
1104
|
+
"kind": 1,
|
|
1105
|
+
"detail": "Wait for background processes",
|
|
1106
|
+
"documentation": { "value": "Wait for background jobs to complete.\n\n```bash\ncommand1 &\ncommand2 &\nwait # wait for all\nwait $pid # wait for specific PID\nwait -n # wait for any one job\n```" },
|
|
1107
|
+
"insertText": "wait ${1}",
|
|
1108
|
+
"insertTextRules": 4,
|
|
1109
|
+
"sortText": "00_wait"
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
"label": "jobs",
|
|
1113
|
+
"kind": 1,
|
|
1114
|
+
"detail": "List active jobs",
|
|
1115
|
+
"documentation": { "value": "Display status of jobs in the current session.\n\n```bash\njobs\njobs -l # include PID\njobs -p # PIDs only\n```" },
|
|
1116
|
+
"insertText": "jobs",
|
|
1117
|
+
"insertTextRules": 4,
|
|
1118
|
+
"sortText": "00_jobs"
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
"label": "bg",
|
|
1122
|
+
"kind": 1,
|
|
1123
|
+
"detail": "Resume job in background",
|
|
1124
|
+
"documentation": { "value": "Resume a suspended job in the background.\n\n```bash\nbg # resume last stopped job\nbg %1 # resume job 1\n```" },
|
|
1125
|
+
"insertText": "bg",
|
|
1126
|
+
"insertTextRules": 4,
|
|
1127
|
+
"sortText": "00_bg"
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"label": "fg",
|
|
1131
|
+
"kind": 1,
|
|
1132
|
+
"detail": "Resume job in foreground",
|
|
1133
|
+
"documentation": { "value": "Bring a background job to the foreground.\n\n```bash\nfg # bring last job to foreground\nfg %1 # bring job 1 to foreground\n```" },
|
|
1134
|
+
"insertText": "fg",
|
|
1135
|
+
"insertTextRules": 4,
|
|
1136
|
+
"sortText": "00_fg"
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
"label": "kill",
|
|
1140
|
+
"kind": 1,
|
|
1141
|
+
"detail": "Send signal to a process",
|
|
1142
|
+
"documentation": { "value": "Send a signal to a process.\n\n```bash\nkill $pid\nkill -9 $pid # SIGKILL (force)\nkill -TERM $pid # SIGTERM (graceful)\nkill -HUP $pid # SIGHUP (reload)\nkill %1 # kill job 1\n```" },
|
|
1143
|
+
"insertText": "kill ${1:pid}",
|
|
1144
|
+
"insertTextRules": 4,
|
|
1145
|
+
"sortText": "02_kill"
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
"label": "pushd",
|
|
1149
|
+
"kind": 1,
|
|
1150
|
+
"detail": "Push directory onto stack",
|
|
1151
|
+
"documentation": { "value": "Save current directory and change to a new one.\n\n```bash\npushd /some/dir # save cwd, cd to /some/dir\npopd # return to saved directory\n```" },
|
|
1152
|
+
"insertText": "pushd ${1:directory}",
|
|
1153
|
+
"insertTextRules": 4,
|
|
1154
|
+
"sortText": "00_pushd"
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
"label": "popd",
|
|
1158
|
+
"kind": 1,
|
|
1159
|
+
"detail": "Pop directory from stack",
|
|
1160
|
+
"documentation": { "value": "Return to the directory saved by pushd.\n\n```bash\npushd /tmp\n# ... work in /tmp ...\npopd # return to previous directory\n```" },
|
|
1161
|
+
"insertText": "popd",
|
|
1162
|
+
"insertTextRules": 4,
|
|
1163
|
+
"sortText": "00_popd"
|
|
1164
|
+
},
|
|
1165
|
+
{
|
|
1166
|
+
"label": "mapfile",
|
|
1167
|
+
"kind": 1,
|
|
1168
|
+
"detail": "Read lines into an array",
|
|
1169
|
+
"documentation": { "value": "Read lines from stdin into an indexed array.\n\n```bash\nmapfile -t lines < file.txt\nmapfile -t words < <(echo \"a b c\" | tr ' ' '\\n')\nreadarray -t arr < file.txt # alias for mapfile\n```" },
|
|
1170
|
+
"insertText": "mapfile -t ${1:array} < ${2:file}",
|
|
1171
|
+
"insertTextRules": 4,
|
|
1172
|
+
"sortText": "00_mapfile"
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
"label": "readarray",
|
|
1176
|
+
"kind": 1,
|
|
1177
|
+
"detail": "Read lines into an array (alias for mapfile)",
|
|
1178
|
+
"documentation": { "value": "Read lines from stdin into an indexed array. Alias for `mapfile`.\n\n```bash\nreadarray -t lines < file.txt\n```" },
|
|
1179
|
+
"insertText": "readarray -t ${1:array} < ${2:file}",
|
|
1180
|
+
"insertTextRules": 4,
|
|
1181
|
+
"sortText": "00_readarray"
|
|
1182
|
+
}
|
|
1183
|
+
]
|
|
1184
|
+
}
|