FormatCodes
首页/Shell 工具/Shell 格式化

Shell / Bash 格式化工具

在线格式化和校验 Shell / Bash 脚本,基于 shfmt,直接在浏览器中完成处理。

浏览器本地处理
无需登录
基于 shfmt
语言
Shellscript.sh
缩进
输入可编辑
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
输出Shell 有效31 行 · 682 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Deploy script
APP_NAME="myapp"
DEPLOY_DIR="/var/www/$APP_NAME"
LOG_FILE="/var/log/$APP_NAME/deploy.log"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOG_FILE"
}
check_deps() {
for cmd in git docker curl; do
if ! command -v "$cmd" &>/dev/null; then
log "ERROR: $cmd is not installed"
return 1
fi
done
}
deploy() {
local branch="${1:-main}"
log "Deploying branch: $branch"
cd "$DEPLOY_DIR" || { log "ERROR: Cannot cd to $DEPLOY_DIR"; exit 1; }
git fetch origin && git checkout "$branch" && git pull origin "$branch"
docker build -t "$APP_NAME:latest" . && docker-compose up -d --remove-orphans
log "Deploy complete"
}
check_deps || exit 1
deploy "$@"
UTF-8 · Tab · shfmt本地处理 · 就绪
工具说明Shell
简介
把缩进混乱或风格不统一的 Shell / Bash 脚本重新整理成标准格式,底层使用 shfmt 的 WebAssembly 编译版本。支持 Tab 和空格缩进、switch-case 缩进、管道换行等选项。所有处理都在浏览器本地完成,脚本内容不会离开你的设备。
场景
格式化粘贴自文档或 AI 生成的 Shell 脚本统一团队 CI/CD 脚本风格整理缩进混乱的旧脚本校验 Shell 语法是否正确
使用步骤
123
粘贴或上传调整格式选项获取结果

相关工具

相关指南

常见问题

搜索工具

搜索 55+ 个格式化、转换、压缩、对比与生成工具