Shell Scripts
Shell Scripts (bash, zsh, dash, sh) are supported natively by Gram.
- Tree-sitter: tree-sitter/tree-sitter-bash
Settings
You can configure various settings for Shell Scripts in your Gram User Settings (~/.config/gram/settings.json) or Gram Project Settings (.gram/settings.json):
"languages": {
"Shell Script": {
"tab_size": 2,
"hard_tabs": false
}
}
Formatting
Gram supports auto-formatting Shell Scripts using external tools like shfmt.
- Install
shfmt:
brew install shfmt # macos (homebrew)
sudo apt-get install shfmt # debian/ubuntu
dnf install shfmt # fedora
yum install shfmt # redhat
pacman -Sy shfmt # archlinux
choco install shfmt # windows (chocolatey)
- Ensure
shfmtis available in your path and check the version:
which shfmt
shfmt --version
- Configure Gram to automatically format Shell Scripts with
shfmton save:
"languages": {
"Shell Script": {
"format_on_save": "on",
"formatter": {
"external": {
"command": "shfmt",
// Change `--indent 2` to match your preferred tab_size
"arguments": ["--filename", "{buffer_path}", "--indent", "2"]
}
}
}
}