Skip to content

feat: 提升 Zsh 重置安全性与启动性能#40

Merged
ChangeHow merged 9 commits into
mainfrom
feat/zsh-setup-experience
Jul 10, 2026
Merged

feat: 提升 Zsh 重置安全性与启动性能#40
ChangeHow merged 9 commits into
mainfrom
feat/zsh-setup-experience

Conversation

@ChangeHow

@ChangeHow ChangeHow commented Jul 10, 2026

Copy link
Copy Markdown
Owner

背景

  • 当前旧 Zsh 配置热启动主要受 zplug install/load、重复 compinit 和工具初始化影响。
  • Reset/clean 需要更安全地保留用户自己的 alias 和本地配置。

改动

  • 新增用户自有 alias 文件 ~/.config/zsh/local/aliases.zsh,setup/append 初始化并加载,clean/reset 保留。
  • 自动迁移旧 ~/.config/suitup/aliases 中有效、无冲突的单行 alias;同名 alias 和非 alias 内容保留在旧文件并只报告数量。
  • 对 aliases 的 managed diff 预览做值脱敏,避免泄漏命令中的 token 或本地路径。
  • 优化 Zsh 启动路径:Homebrew shellenv 只检查一次、completion 使用 zsh glob + zcompile、fzf Ctrl-T 兼容旧版 fzf/tmux、启动报告默认只在 >=100ms 时显示。
  • 使用 fnm 原生 fnm install --lts --use && fnm default "$(fnm current)" 安装最新 Node LTS,移除 curl/jq 查询和固定版本兜底。
  • 同步更新 README / README.zh-CN / AGENTS 与相关测试。

验证

  • npm test
  • 12 个 Zsh 检查通过
  • 22 个 Vitest 文件、224 个用例通过

关注点

  • Legacy alias 只迁移有效、无冲突的单行 alias;多行 alias、export 和可能包含密钥的内容不会自动写入新文件。
  • 实际本机重置前仍需把旧 .zshrc / legacy aliases 中的本地环境变量或凭据手动迁移到 local/machine.zshlocal/secrets.zsh

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces user-owned aliases (~/.config/zsh/local/aliases.zsh) that are preserved across updates and clean/reset flows, including migration logic for legacy aliases with sensitive value redaction. It also optimizes Homebrew path initialization, hides fast startup timing reports by default, improves fzf tmux integration, and compiles the zsh completion dump. The review feedback highlights two important issues: first, the glob pattern for checking the completion cache should be tightened to exclude empty files (using N.m-7L+0 instead of Nm-7) to prevent loading errors; second, the legacy alias syntax validation using spawnSync should explicitly check for a null status to avoid false validation failures in environments where zsh is not installed.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread configs/shared/completion.zsh Outdated
Comment thread src/steps/aliases.js
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

Zsh startup benchmark

Ubuntu 24.04 with Linuxbrew, atuin, fnm, fzf, zoxide, zinit, and the shipped plugins. Lower is better.

Warm startup (daily use)

Command Mean [ms] Min [ms] Max [ms] Relative
current (6f7c107) 88.8 ± 0.9 87.6 90.9 1.00
main (35899ca) 116.6 ± 2.1 115.1 127.0 1.31 ± 0.03
previous commit (4ecde9b) 89.2 ± 1.0 88.0 91.3 1.00 ± 0.02

Cache-miss startup

Completion and tool-init caches are removed before every run; installed tools and plugins remain.

Command Mean [ms] Min [ms] Max [ms] Relative
current (6f7c107) 689.6 ± 3.2 684.7 694.1 1.00
main (35899ca) 722.5 ± 22.5 711.7 784.1 1.05 ± 0.03
previous commit (4ecde9b) 691.0 ± 3.8 684.5 697.6 1.00 ± 0.01

@ChangeHow
ChangeHow merged commit d343526 into main Jul 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant