可复制命令
此页把常用工作站操作整理成小块可复制命令。命令按安全等级分组,让新机器设置过程保持可见和可恢复。
命令规则
- 一个命令块只做一个阶段。
- 对会写入机器的命令,先运行检查和 dry-run。
- 保留交互式命令,同时记录非交互等价命令。
- 当命令无法安全继续时,打印或记录下一步。
- 把包管理器清单作为事实来源,不把安装逻辑藏在临时脚本里。
新机器
如果机器还没有 Homebrew,先安装它:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"把 Homebrew 加载到当前 shell:
eval "$(/opt/homebrew/bin/brew shellenv)"安装 ghq 并配置标准项目根目录:
brew install ghq
git config --global ghq.root ~/repos确认 ghq 项目根目录:
git config --global --get ghq.root按 ghq 布局 clone 此仓库:
ghq get git@github.com:YunYouJun/workstation.git
cd "$(ghq list -p github.com/YunYouJun/workstation)"如果暂时没有 ghq,也可以直接 clone 到同一路径:
mkdir -p ~/repos/github.com/YunYouJun
git clone git@github.com:YunYouJun/workstation.git ~/repos/github.com/YunYouJun/workstation
cd ~/repos/github.com/YunYouJun/workstation安装仓库声明的软件包:
brew bundle --file Brewfile安装默认 Node.js 运行时:
fnm install --lts
fnm default lts-latest安装可选桌面应用:
pnpm software:install --apps安装工作区依赖并构建 CLI:
pnpm install
pnpm build安全检查
检查当前 dotfiles 状态:
workstation dotfiles doctor
workstation dotfiles status
workstation dotfiles diff查看可用初始化任务:
wst init --list预览 Git includeIf 身份路由初始化:
wst init git.include-if --git-profile 'id=github;host=github.com;name=Your Name;email=you@example.com'预览从仓库恢复到 $HOME:
workstation dotfiles pull --dry-run预览从 $HOME 保存回仓库:
workstation dotfiles push --dry-run预览 clone 最近活跃的 YunYouJun 仓库:
workstation projects clone-active预览 clone 最近活跃的 20 个 YunYouJun 仓库:
workstation projects clone-active --limit 20用短别名预览同一件事:
wst p active --limit 20交互式选择要处理的仓库:
wst p active --limit 50 -i预览从本地项目清单 clone:
wst p manifest --file projects.local.yaml预览从私有配置仓库读取项目清单:
wst p manifest https://git.example.com/<user>/<config-repo> --group common用脚本入口和环境变量配置默认数量:
WORKSTATION_ACTIVE_PROJECT_LIMIT=20 pnpm projects:clone-active检查本地项目是否有未提交、未 push 或 stash:
workstation projects status
wst p status --check
wst p status --max-depth 8
pnpm projects:status检查 Homebrew 包是否已安装:
brew bundle check --file Brewfile检查可选桌面应用是否已安装:
pnpm software:check --apps显示软件目录中缺失的应用:
pnpm software:missing打开所选应用的官方下载页:
pnpm software:open microsoft-todo vscode neteasemusic qq wechat codex chrome raycast feishu应用更改
检查 dry-run 输出后,把管理的 dotfiles 恢复到 $HOME:
workstation dotfiles pull --force检查 dry-run 输出后,把本地 dotfile 变更保存回仓库:
workstation dotfiles push --force直接应用 chezmoi 管理的文件:
workstation dotfiles chezmoi apply检查 dry-run 输出后,应用 Git includeIf 身份路由:
wst init git.include-if --git-profile 'id=github;host=github.com;name=Your Name;email=you@example.com' --yes检查 dry-run 输出后,clone 最近活跃的 YunYouJun 仓库:
workstation projects clone-active --yes重启当前 shell:
exec zsh交互流程
当需要手动选择方向和文件时,使用交互式同步:
workstation dotfiles sync -i当需要选择初始化任务并输入本机身份信息时,使用交互式初始化:
wst init -i等价的非交互恢复流程:
workstation dotfiles sync --direction pull --dry-run
workstation dotfiles sync --direction pull --force等价的非交互保存流程:
workstation dotfiles sync --direction push --dry-run
workstation dotfiles sync --direction push --force发布 CLI
首次使用 GitHub Actions 发布前,先在 npm package settings 为 @yunyoujun/workstation 配置 Trusted Publisher:
Publisher: GitHub Actions
Repository: YunYouJun/workstation
Workflow filename: release.yml
Allowed action: npm publish发布新版本:
pnpm release
git push --follow-tags推送 v* tag 后,GitHub Actions 会校验并发布 packages/cli。
未来命令
仓库超出 dotfiles 范围后,推荐使用更宽泛的 workstation 命令和领域子命令,同时保留 dotfiles 作为现有同步工作流的兼容别名。
workstation doctor
workstation bootstrap --dry-run
workstation packages install --dry-run
workstation dotfiles pull --dry-run
workstation projects clone-active