โ๏ธ Working on bash
[!INFORMATION] Disclaimer: This page is just one opinion. This is not the best way to work on bash scripts, this is just an explanation of how I work.
๐งโ๐ป VS Code
I work with VS code and git bash on Windows.
WSL and the GitHub actions allow me to test Valet on different Linux distributions.
โ๏ธ Settings
After creating a new extension, you can open the extension directory as a workspace on vscode.
It will come pre-configured with vscode snippets, settings, and extension recommendations.
๐งฉ Extensions
Here is a list of recommended extensions to work on bash scripts:
- Bash IDE
- Debug bash scripts
- Shell Script Command Completion
- Better comments
- Better shellscript syntax
- Code spell checker
- EditorConfig
- Indent rainbow
- Format shell script
- Shellcheck
- Snippets manager
- Snippets for bash scripts
- Snippets for shebang
A more up-to-date list can be found here.
๐ Autocompletion on Valet library functions
You can use the Valet vscode snippets which should already be present in your extension directory. If not, you can setup your directory with valet self extend .
.
Additionally, the already configured .vscode/settings.json
will contain the following settings:
{
"bashIde.globPattern": "**/@(lib-*|commands.d/*.sh)",
"bashIde.includeAllWorkspaceSymbols": true,
"terminal.integrated.wordSeparators": " ()[]{}',\"`โโโโโ|โโ"
}
It will allow you to navigate to the function definitions with F12
and Ctrl+click
on the function calls.
You should have autocompletion and help on all ibrary functions:
๐ฎ shellcheck
If you have installed the recommended extensions, you will also have shellcheck which will attempt to following the sourced files in your project. You should annotate each source
statement for shellcheck to use the lib-valet
file:
# shellcheck source=../lib-valet
source string