Creating snippets using VS Code

For those who love graphical IDEs, you can use VS Code as an editor for your shell scripts. We used it as a debugger in Chapter 1, The What and Why of Scripting with Bash. Now we will see one of its capabilities as an editor.

You can create your own snippets in VS Code as follows.

Navigate to File | Preferences | User Snippets.

Then start to type shell. This will open the shellscript.json file.

The file has two brackets ready to enter your snippets between them:

To create a snippet, type the following between the brackets on the file:

"Print a welcome message": {   "prefix": "welcome",   "body": [ "echo 'Welcome ...

Get Mastering Linux Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.