Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ The actual config lives under `~/.config/zsh/`.

### Shared files

- `configs/shared/tools.zsh`: external tool initialization, including cached init scripts
- `configs/shared/tools.zsh`: thin orchestrator that sources `shared/tools/_loader.zsh` and calls `_load_tool_config` for each tool module
- `configs/shared/tools/_loader.zsh`: `_load_tool_config()` helper and `_source_cached_tool_init()` with version-based cache invalidation
- `configs/shared/tools/{tool}.zsh`: per-tool module files (fzf, runtime, atuin, bun), loaded on demand by `_load_tool_config`
- `configs/shared/prompt.zsh`: prompt/theme loading

### Local files
Expand Down Expand Up @@ -74,3 +76,15 @@ This step must remain idempotent.

- `README.md`: end-user usage, installed tools, resulting file layout
- `AGENTS.md`: implementation details, architecture, contributor guidance

## Documentation Sync — REQUIRED

`README.md` is the source of truth. `README.zh-CN.md` is its Simplified Chinese translation.

**You MUST update both files in the same commit** whenever changes affect user-facing content (features, commands, file paths, install behavior, directory layout). Updating one without the other is never acceptable.

Checklist for README changes:
- Paths and directory structures match between both files
- Command tables and descriptions reflect the current behavior
- `install.sh` default behavior is accurately described in both files
- The installed file layout section reflects the current shipped config structure
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Named after Barney's catchphrase from [How I Met Your Mother](https://www.themov
- **Verify mode** — check your installation integrity
- **Clean mode** — remove suitup config files
- `--help` output for quick command discovery
- Backs up existing zsh startup files to `~/.config/suitup/backups/` before changing shell startup config
- Backs up existing zsh startup files to `~/.config/zsh/backups/` before changing shell startup config
- Powerlevel10k is optional; recommended because its async git status stays responsive in large repositories
- Idempotent — safe to run multiple times
- No private/company-specific content — clean, generic configs
Expand All @@ -48,7 +48,13 @@ When you run suitup locally from the repo, use a zsh session. The curl installer
curl -fsSL https://raw.githubusercontent.com/ChangeHow/suitup/main/install.sh | bash
```

The installer now defaults to `init`, bootstraps missing `zsh` and Node.js/npm when possible, downloads a temporary copy of the repo, runs `npm ci`, and launches suitup inside `zsh`.
The installer bootstraps missing `zsh` and Node.js/npm when possible, downloads a temporary copy of the repo, runs `npm ci`, then asks whether you want interactive `setup` or non-interactive `init` before launching inside `zsh`.

You can also pass a command directly to skip the prompt:

```bash
curl -fsSL https://raw.githubusercontent.com/ChangeHow/suitup/main/install.sh | bash -s -- init
```

`init` is a non-interactive quick-start path that uses recommended defaults:

Expand All @@ -58,14 +64,15 @@ The installer now defaults to `init`, bootstraps missing `zsh` and Node.js/npm w
- install recommended CLI tools and frontend tooling
- install recommended GUI apps on macOS
- write shared aliases
- run `p10k configure` at the end to set up your prompt theme

You can also pass a specific command to the installer:
You can also pass any other command:

```bash
curl -fsSL https://raw.githubusercontent.com/ChangeHow/suitup/main/install.sh | bash -s -- clean
```

If you want append mode directly without the prompt:
If you want append mode directly:

```bash
curl -fsSL https://raw.githubusercontent.com/ChangeHow/suitup/main/install.sh | bash -s -- append
Expand Down Expand Up @@ -111,7 +118,7 @@ Interactive step-by-step setup with selectable steps:
10. **Vim Config** — basic vim setup
11. **Dock Cleanup** — clean macOS Dock

Before suitup updates shell startup config, it backs up existing zsh startup files such as `.zshrc`, `.zprofile`, `.zshenv`, and `.zlogin` to `~/.config/suitup/backups/`.
Before suitup updates shell startup config, it backs up existing zsh startup files such as `.zshrc`, `.zprofile`, `.zshenv`, and `.zlogin` to `~/.config/zsh/backups/`.

If you choose Powerlevel10k, suitup keeps prompt loading non-interactive during setup. When `~/.p10k.zsh` is missing, it falls back to a basic prompt until you run `p10k configure` yourself.

Expand Down Expand Up @@ -162,7 +169,7 @@ This command:

- extracts detected PATH-related lines from `.zshrc`
- appends them to `~/.config/zsh/core/paths.zsh`
- creates a backup in `~/.config/suitup/backups/`
- creates a backup in `~/.config/zsh/backups/`
- runs a post-migration Zsh syntax check
- rolls back automatically if validation fails

Expand All @@ -175,7 +182,7 @@ node src/cli.js clean
Attempts a safe uninstall of suitup-managed config:

- restores the latest non-suitup backup of `~/.zshrc` / `~/.zshenv` when available
- removes suitup-generated `~/.config/zsh/` and `~/.config/suitup/` files when they still match shipped templates
- removes suitup-generated `~/.config/zsh/` files when they still match shipped templates
- strips `# >>> suitup/... >>>` blocks from an existing `~/.zshrc` if you used `append`
- preserves user-modified files instead of deleting them blindly

Expand Down Expand Up @@ -231,17 +238,22 @@ After setup, your shell config looks like:
paths.zsh # PATH + tool bootstrap entries
options.zsh # Zsh shell options
shared/
tools.zsh # Tool init (fzf, atuin, zoxide, fnm)
tools.zsh # Tool init orchestrator
tools/
_loader.zsh # _load_tool_config() + version-based cache
fzf.zsh # FZF env, init, Ctrl-T widget
runtime.zsh # zoxide + fnm
atuin.zsh # Atuin history (owns Ctrl-R)
bun.zsh # Bun async completion
plugins.zsh # zinit plugin declarations
highlighting.zsh # zsh-syntax-highlighting styles
aliases.zsh # Shared aliases
completion.zsh # Native completion setup
prompt.zsh # Prompt/theme (p10k)
local/
machine.zsh # Machine-specific overrides
config.vim # Vim config
secrets.zsh # API keys (create manually, gitignored)
~/.config/suitup/
config.vim # Vim config
```

## Testing
Expand Down
94 changes: 61 additions & 33 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
## 特性

- 基于 [@clack/prompts](https://github.com/bombshell-dev/clack) 的交互式终端界面
- suitup 现在只支持 zsh;所有命令都需要在 zsh 会话中运行
- suitup 只支持 zsh;所有命令都需要在 zsh 会话中运行
- 模块化步骤选择,只安装你需要的内容
- **追加模式**:向现有 `.zshrc` 追加推荐配置,不强制覆盖
- **PATH 迁移模式**:把 `.zshrc` 里的 PATH / 工具初始化行迁移到 `~/.config/zsh/core/paths.zsh`
- **验证模式**:检查安装完整性
- **清理模式**:删除 suitup 生成的配置
- 提供 `--help`,方便快速查看命令
- 修改 Shell 启动配置前,会先把现有 zsh 启动文件备份到 `~/.config/suitup/backups/`
- 修改 Shell 启动配置前,会先把现有 zsh 启动文件备份到 `~/.config/zsh/backups/`
- Powerlevel10k 为可选项;推荐开启,因为它在大型 Git 仓库里的异步 git 状态会更流畅
- 幂等执行,可安全重复运行
- 不包含私有/公司特定内容
Expand All @@ -40,23 +40,39 @@ Suitup 可以帮你初始化 Zsh 和 Homebrew,但更稳妥的路径仍然是

### 安装并运行

suitup 现在默认你已经安装好 zsh,并且当前就在 zsh 会话里运行命令
在本地从仓库运行 suitup 时,请使用 zsh 会话。curl 安装脚本可以在全新机器上自动补全缺少的依赖

### 通过 curl 快速安装

```bash
curl -fsSL https://raw.githubusercontent.com/ChangeHow/suitup/main/install.sh | bash
```

这个安装脚本会先询问你要走 `init`(完整 setup)还是 `append`(给现有 `.zshrc` 做增量补充),然后临时下载仓库、执行 `npm ci`,最后在 `zsh` 中启动对应的 `node src/cli.js` 命令
安装脚本会在必要时自动安装 `zsh` 和 Node.js/npm,临时下载仓库,执行 `npm ci`,然后询问你想要交互式 `setup` 还是非交互式 `init`,再在 `zsh` 中启动对应流程

如果你想直接执行某个命令,也可以这样传参:
你也可以直接传入命令来跳过询问:

```bash
curl -fsSL https://raw.githubusercontent.com/ChangeHow/suitup/main/install.sh | bash -s -- init
```

`init` 是非交互式快速初始化路径,使用推荐默认值:

- 按需安装包管理器和 zsh
- 安装分层 zsh 配置
- 安装 zinit + Powerlevel10k 预设
- 安装推荐 CLI 工具和前端工具链
- 在 macOS 上安装推荐 GUI 应用
- 写入共享 aliases
- 最后运行 `p10k configure` 完成提示符主题配置

你也可以传入其他命令:

```bash
curl -fsSL https://raw.githubusercontent.com/ChangeHow/suitup/main/install.sh | bash -s -- clean
```

如果你想跳过提示、直接进入 append 模式,也可以这样运行
如果想直接进入 append 模式:

```bash
curl -fsSL https://raw.githubusercontent.com/ChangeHow/suitup/main/install.sh | bash -s -- append
Expand All @@ -75,6 +91,7 @@ node src/cli.js

| 命令 | 说明 |
|------|------|
| `node src/cli.js init` | 非交互式快速初始化,使用推荐默认值 |
| `node src/cli.js` | 完整交互式安装(默认) |
| `node src/cli.js setup` | 同上 |
| `node src/cli.js append` | 追加配置到已有 `.zshrc` |
Expand All @@ -89,7 +106,7 @@ node src/cli.js

交互式步骤如下:

1. **Bootstrap** — 包管理器 + Zsh(macOS 可安装/跳过 Homebrew;Linux 可选 apt-get/dnf/yum/brew/跳过)
1. **Bootstrap** — 包管理器 + Zsh
2. **Zsh Config** — 创建 `~/.config/zsh/` 分层结构
3. **Plugin Manager** — zinit(推荐)或跳过,仅保留原生 zsh
4. **Prompt Preset** — Powerlevel10k(推荐)或基础 zsh prompt
Expand All @@ -101,17 +118,17 @@ node src/cli.js
10. **Vim Config** — 基础 Vim 配置
11. **Dock Cleanup** — 清理 macOS Dock

在 suitup 修改 Shell 启动配置前,会先把现有 `.zshrc`、`.zprofile`、`.zshenv`、`.zlogin` 等 zsh 启动文件备份到 `~/.config/suitup/backups/`。
在 suitup 修改 Shell 启动配置前,会先把现有 `.zshrc`、`.zprofile`、`.zshenv`、`.zlogin` 等 zsh 启动文件备份到 `~/.config/zsh/backups/`。

如果你选择 Powerlevel10k,suitup 会保持安装过程非交互;当缺少 `~/.p10k.zsh` 时,会先回退到基础 prompt,等你之后自行运行 `p10k configure` 再启用。

Bootstrap 细节:

- macOS:安装 Homebrew,或跳过包管理器初始化
- Linux:可选 `apt-get`、`dnf`、`yum`、`brew`,或直接跳过
- 如果 Homebrew 已经安装在非默认位置,suitup 现在会在 Zsh 启动时自动尝试常见 `shellenv` 路径
- suitup 现在也会生成一个精简的 `~/.zshenv`,保证非交互式 shell 也能加载共享环境变量和 PATH
- 当 fnm 安装 Node.js 后,suitup 会把 `fnm` 自身和该默认 Node 版本一起放进 PATH,确保交互式/非交互式 shell 下的 `fnm`、`node`、`npm` 和全局 CLI 都优先指向 fnm 管理的路径
- 如果 Homebrew 已经安装在非默认位置,suitup 会在 Zsh 启动时自动尝试常见 `shellenv` 路径
- suitup 也会生成一个精简的 `~/.zshenv`,保证非交互式 shell 也能加载共享环境变量和 PATH
- 当 fnm 安装 Node.js 后,suitup 会把 `fnm` 自身和该默认 Node 版本一起放进 PATH,确保交互式/非交互式 shell 下的 `fnm`、`node`、`npm` 和全局 CLI 都能正确解析

### Append(追加)

Expand All @@ -126,7 +143,7 @@ node src/cli.js append
- aliases
- zinit 插件
- Powerlevel10k prompt 或基础 prompt 预设(会替换 `~/.config/zsh/shared/prompt.zsh`)
- 工具初始化(atuin/fzf/zoxide/fnm)
- 工具初始化(atuinfzfzoxidefnm)
- Zsh 选项(history/completion)
- 环境变量
- 启动性能报告
Expand All @@ -152,7 +169,7 @@ node src/cli.js migrate-paths

- 从 `.zshrc` 中提取识别到的 PATH 相关配置
- 追加到 `~/.config/zsh/core/paths.zsh`
- 先创建 `~/.config/suitup/backups/` 备份
- 先创建 `~/.config/zsh/backups/` 备份
- 迁移后执行 Zsh 语法检查
- 如果校验失败则自动回滚

Expand All @@ -164,8 +181,8 @@ node src/cli.js clean

尽量安全地卸载 suitup 管理的配置:

- 若存在备份,优先恢复最近一次非 suitup 版本的 `~/.zshrc` / `~/.zshenv`
- 对仍与项目模板一致的文件,删除 `~/.config/zsh/` 与 `~/.config/suitup/` 下的 suitup 生成内容
- 若存在备份,优先恢复最近一次"非 suitup 版本"的 `~/.zshrc` / `~/.zshenv`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the typography used elsewhere in this document, it is recommended to use Chinese full-width quotation marks (“”) instead of English double quotes ("").

Suggested change
- 若存在备份,优先恢复最近一次"非 suitup 版本"`~/.zshrc` / `~/.zshenv`
- 若存在备份,优先恢复最近一次非 suitup 版本`~/.zshrc` / `~/.zshenv`

- 对仍与项目模板一致的文件,删除 `~/.config/zsh/` 下的 suitup 生成内容
- 如果你用过 `append`,会从现有 `~/.zshrc` 中移除 `# >>> suitup/... >>>` 标记块
- 对用户自己改过的文件会保留,不会盲删

Expand Down Expand Up @@ -209,7 +226,7 @@ node src/cli.js --help

## 安装后的目录结构

```text
```
~/.zshrc # 轻量入口
~/.zshenv # 非交互式 shell 的最小环境入口
~/.config/zsh/
Expand All @@ -219,32 +236,43 @@ node src/cli.js --help
paths.zsh # PATH 与工具引导配置
options.zsh # Zsh 选项
shared/
tools.zsh # 工具初始化(带缓存)
prompt.zsh # 提示符主题
tools.zsh # 工具初始化编排入口
tools/
_loader.zsh # _load_tool_config() + 版本化缓存
fzf.zsh # FZF 环境变量、初始化、Ctrl-T 组件
runtime.zsh # zoxide + fnm
atuin.zsh # Atuin 历史(占用 Ctrl-R)
bun.zsh # Bun 异步补全
plugins.zsh # zinit 插件声明
highlighting.zsh # zsh-syntax-highlighting 样式
aliases.zsh # 共享 aliases
completion.zsh # 原生补全配置
prompt.zsh # 提示符主题(p10k)
local/
machine.zsh # 机器本地覆盖
secrets.zsh # 个人密钥(手动创建)
~/.config/suitup/
aliases # Shell aliases
zinit-plugins # Zinit 插件配置
config.vim # Vim 配置
config.vim # Vim 配置
secrets.zsh # 个人密钥(手动创建,不纳入 git)
```

## 系统要求

- Node.js >= 18
- 已安装 Zsh
- 需要在 zsh 会话中运行 suitup(`echo $SHELL` 结果应以 `zsh` 结尾)
- macOS(完整支持)
- Linux(支持 bootstrap 包管理器选择;其余安装步骤当前仍以 Homebrew 生态为主)

## 测试

```bash
npm test
npm run test:watch
npm test # 运行全套测试
npm run test:watch # 监视模式
```

测试在沙箱临时目录中运行。

实现细节和架构说明见 `AGENTS.md`。

## 系统要求

- macOS(完整支持,在 Sonoma+ 上测试)
- Linux(支持 bootstrap 包管理器选择;其余安装步骤当前仍以 Homebrew 生态为主)
- 本地运行需要 Node.js >= 18;curl 安装脚本会在可能时自动安装
- 本地运行需要 Zsh;curl 安装脚本会在可能时自动安装
- 需要在 zsh 会话中运行 suitup(`echo $SHELL` 结果应以 `zsh` 结尾)

## 许可证

[Apache-2.0](LICENSE)
14 changes: 9 additions & 5 deletions configs/core/perf.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ _print_duration_row() {
if (( rounded_ms > 1000 )); then
local sec=$(( rounded_ms / 1000 ))
local rem=$(( rounded_ms % 1000 ))
printf '│ %-8s %12d.%01ds │\n' "$name" "$sec" "$(( rem / 100 ))"
printf '│ %-10s %12d.%01ds │\n' "$name" "$sec" "$(( rem / 100 ))"
else
printf '│ %-8s %13dms │\n' "$name" "$rounded_ms"
printf '│ %-10s %13dms │\n' "$name" "$rounded_ms"
fi
}

Expand All @@ -66,13 +66,17 @@ _zsh_report() {
local i

echo ''
echo '┌──────────────────────────┐'
echo '┌────────────────────────────┐'

for i in {1..${#_zsh_stage_names}}; do
_print_duration_row "${_zsh_stage_names[$i]}" "${_zsh_stage_durations[$i]}"
done

echo '├──────────────────────────┤'
echo '├────────────────────────────┤'
_print_duration_row 'total' "$total_ms"
echo '└──────────────────────────┘'
echo '└────────────────────────────┘'

if [[ "${_zsh_completion_cache_mode:-}" == 'cache-hit' && -n "${_zsh_compdump_file:-}" ]]; then
printf 'completion cache hit; remove %s to rebuild\n' "$_zsh_compdump_file"
fi
}
2 changes: 1 addition & 1 deletion configs/shared/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ alias cat="bat"
# git
alias gco="git checkout"
alias gph="git push"
alias gphu='local b; b=$(git rev-parse --abbrev-ref HEAD 2>/dev/null); [[ $b != HEAD ]] && gph -u origin "$b"'
alias gphu='local b; b=$(git branch --show-current 2>/dev/null); [[ -n $b ]] && gph -u origin "$b"'
alias gcol="git checkout --no-guess"
alias gpl="git pull --rebase"
alias gcz="git-cz"
Expand Down
33 changes: 0 additions & 33 deletions configs/shared/fzf.zsh

This file was deleted.

Loading
Loading