1# Shell Scripts
2
3Shell Scripts (bash, zsh, dash, sh) are supported natively by Zed.
4
5- Tree-sitter: [tree-sitter/tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash)
6
7## Settings
8
9You can configure various settings for Shell Scripts in your Zed User Settings (`~/.config/zed/settings.json`) or Zed Project Settings (`.zed/settings.json`):
10
11```json
12 "languages": {
13 "Shell Script": {
14 "tab_size": 2,
15 "hard_tabs": false
16 }
17 }
18```
19
20### Formatting
21
22Zed supports auto-formatting Shell Scripts using external tools like [`shfmt`](https://github.com/mvdan/sh).
23
241. Install `shfmt`:
25
26```sh
27brew install shfmt # macos (homebrew)
28sudo apt-get install shfmt # debian/ubuntu
29dnf install shfmt # fedora
30yum install shfmt # redhat
31pacman -Sy shfmt # archlinux
32choco install shfmt # windows (chocolatey)
33```
34
352. Ensure `shfmt` is available in your path and check the version:
36
37```sh
38which shfmt
39shfmt --version
40```
41
423. Configure Zed to automatically format Shell Scripts with `shfmt` on save:
43
44```json
45 "languages": {
46 "Shell Script": {
47 "format_on_save": "on",
48 "formatter": {
49 "external": {
50 "command": "shfmt",
51 // Change `--indent 2` to match your preferred tab_size
52 "arguments": ["--filename", "{buffer_path}", "--indent", "2"]
53 }
54 }
55 }
56 }
57```
58
59## See also:
60
61- [Zed Docs: Language Support: Bash](./bash.md)
62- [Zed Docs: Language Support: Fish](./fish.md)