configuring-zsh

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Zsh Shell Configuration

Zsh Shell 配置

Quick Reference

快速参考

TopicReference
Startup file orderstartup-files.md
oh-my-zsh patternsoh-my-zsh.md
powerlevel10k setuppowerlevel10k.md
sheldon plugin managersheldon.md
Plugin load orderplugins.md
Performance tuningperformance.md
主题参考文档
启动文件顺序startup-files.md
oh-my-zsh 模式oh-my-zsh.md
powerlevel10k 设置powerlevel10k.md
sheldon 插件管理器sheldon.md
插件加载顺序plugins.md
性能调优performance.md

Workflow Decision Tree

工作流决策树

Need to...Action
Set env vars / PATH / localesRead
startup-files.md
→ edit
.zshenv
or
.zprofile
Configure aliases, keybinds, completions, promptEdit
.zshrc
Fix performance issuesRead
performance.md
→ profile startup
Add/configure pluginsRead
plugins.md
+ relevant manager reference
需求操作
设置环境变量 / PATH / locales阅读
startup-files.md
→ 编辑
.zshenv
或
.zprofile
配置别名、按键绑定、补全和提示符编辑
.zshrc
解决性能问题阅读
performance.md
→ 分析启动性能
添加或配置插件阅读
plugins.md
+ 相关管理器参考文档

Chezmoi Integration

Chezmoi 集成

  • Edit Zsh configs in the chezmoi source (this repo), not directly in
    ~
  • Respect
    {{ ... }}
    template blocks in files
  • Source naming:
    dot_zshrc
    →
    ~/.zshrc
    ,
    private_dot_config/sheldon
    →
    ~/.config/sheldon
  • For chezmoi workflows, see
    managing-chezmoi
    skill
  • 在 chezmoi 源目录(本仓库)中编辑 Zsh 配置,而不是直接在
    ~
    中编辑
  • 遵循文件中的
    {{ ... }}
    模板块
  • 源文件命名:
    dot_zshrc
    →
    ~/.zshrc
    ,
    private_dot_config/sheldon
    →
    ~/.config/sheldon
  • 对于 chezmoi 工作流,请参阅
    managing-chezmoi
    skill

Default Guardrails

默认防护规则

  • Keep
    .zshenv
    idempotent and fast; no external commands
  • No aliases/functions in
    .zshenv
  • Use
    typeset -gx VAR=...
    or
    export VAR=...
    with defensive checks
  • Set
    fpath
    before
    compinit
    ; run
    compinit
    once only
  • Document plugin load order (especially
    zsh-autocomplete
    +
    zsh-syntax-highlighting
    )
  • 确保
    .zshenv
    保持 idempotent 且执行快速;不要调用外部命令
  • 不要在
    .zshenv
    中定义 aliases/functions
  • 使用
    typeset -gx VAR=...
    或
    export VAR=...
    ,并采用防御性检查
  • 在
    compinit
    之前设置
    fpath
    ;仅运行一次
    compinit
  • 记录插件加载顺序(尤其是
    zsh-autocomplete
    +
    zsh-syntax-highlighting
    )

Common Tasks

常见任务

TaskApproach
Add env var
.zshenv
(everywhere) vs
.zprofile
(login) vs
.zshrc
(interactive)
Fix PATHEnsure ordering, remove duplicates, avoid
PATH=$PATH:...
in multiple files
Enable completionsSet
fpath
→
compinit
once → cache if needed
Add pluginChoose manager → ensure correct load order
Setup p10kInstant prompt block first in
.zshrc
→ source
~/.p10k.zsh
after plugins
任务方法
添加环境变量
.zshenv
(所有场景)或
.zprofile
(登录)或
.zshrc
(交互式)
修复 PATH确保顺序正确、移除重复项,避免在多个文件中使用
PATH=$PATH:...
启用补全设置
fpath
→ 仅运行一次
compinit
→ 根据需要使用缓存
添加插件选择管理器 → 确保加载顺序正确
配置 p10k将 instant prompt 代码块放在
.zshrc
的最前面 → 在插件之后 source
~/.p10k.zsh