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 to shell scripting!' "
],
"description": "Print welcome message"
}
You can use the following template and modify it based on your needs.
Try...