入门 Zed Industries 2026-09-14 17:42:20 · 0 阅读
第110章 Zed 编辑器 Shell Script 支持指南
Zed 原生支持 Shell 脚本(bash、zsh、dash、sh)。
- Tree-sitter: tree-sitter/tree-sitter-bash
设置
在设置({#kb zed::OpenSettings})中的 Languages > Shell Script 下配置,或添加到你的设置文件中:
"languages": {
"Shell Script": {
"tab_size": 2,
"hard_tabs": false
}
}
格式化
Zed 支持使用外部工具(如 shfmt)自动格式化 Shell 脚本。
- 安装
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)
- 确保
shfmt在 path 中可用,并检查版本:
which shfmt
shfmt --version
- 在设置({#kb zed::OpenSettings})中的 Languages > Shell Script 下配置格式化,或添加到你的设置文件中:
"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"]
}
}
}
}