Skip to content

fix: shell completions now work for both bash and zsh#2

Merged
wangzhizhou merged 1 commit into
mainfrom
feat/shell-completions
Jun 12, 2026
Merged

fix: shell completions now work for both bash and zsh#2
wangzhizhou merged 1 commit into
mainfrom
feat/shell-completions

Conversation

@wangzhizhou

Copy link
Copy Markdown
Collaborator

问题

Zsh 补全静默失效 — fpath 注入时机太晚,compinit 已执行完毕。且补全只为当前 Shell 配置。

修复

  1. Zsh 补全: 改用 source + 显式 compdef 注册(不再依赖 fpath/compinit 自动发现)
  2. 双 Shell 支持: 新增 _detect_completion_rc_files() 同时检测 bash 和 zsh 的 rc 文件
  3. 卸载清理: _remove_completions() 遍历所有 rc 文件清理补全行
  4. 补全文件: 统一存放于 ~/.easywork/completions/

测试

新增 4 个测试 + 更新 1 个已有测试,全部 115 个测试通过。ShellCheck 通过。

- Fix broken zsh completion: replace fpath/compinit autoload approach
  with direct source + explicit compdef registration
- Add _detect_completion_rc_files() to inject completion into all
  detected shell rc files (bash + zsh), not just the current shell
- Rewrite _remove_completions() to clean up all rc files
- Keep completion files centralized under ~/.easywork/completions/
- Add 4 new tests: explicit compdef, dual-shell injection, cleanup
  preserving user content, idempotent injection
- Update existing test with zsh compdef and fpath assertions
@wangzhizhou wangzhizhou merged commit 0540040 into main Jun 12, 2026
2 checks passed
@wangzhizhou wangzhizhou deleted the feat/shell-completions branch June 12, 2026 11:58
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