✍️ Working on bash

✍️ Working on bash

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:

A more up-to-date list can be found in extensions.json.

Dependencies

For those extensions to work, you will need to install: shfmt, shellcheck.

🆎 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:

autocompletion
Autocompletion with VS code

👮 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

🚲 Where to start your bash journey