Skip to content

Bash

Shell scripts are supported out of the box. The language is called Shell Script in Tyrn and covers .sh, .bash, .zsh and common dotfiles such as .bashrc and .zshrc. Files that start with a #! line for sh, bash, zsh or dash are detected too.

Feature Provided by
Language server bash-language-server
Diagnostics shellcheck, when installed

Tyrn uses bash-language-server from your PATH if found, and otherwise installs it with Node.

Install shellcheck

bash-language-server relies on shellcheck for diagnostics. Without it you still get completions and navigation, but no warnings.

Terminal window
brew install shellcheck

Check it is on your path:

Terminal window
which shellcheck

To control which warnings you see, add a .shellcheckrc to your project or home folder. For example:

.shellcheckrc
disable=SC2086

See the ShellCheck wiki for the options.

Run a script

Open a .sh or .bash file and press cmd-shift-r. The script appears in the task list, tagged bash-script. To pass arguments, add a task:

.tyrn/tasks.json
[
{
"label": "run my-script.sh with args",
"command": "./my-script.sh",
"args": ["--verbose", "--output=results.txt"],
"tags": ["bash-script"]
}
]

Tasks run in a login shell. See Tasks.

Settings

Set indentation for shell scripts:

settings.json
{
"languages": {
"Shell Script": { "tab_size": 2 }
}
}

To treat other files as shell scripts:

settings.json
{
"file_types": {
"Shell Script": ["envrc.local", "scripts/*"]
}
}