使用 zimfw 配置 zsh
zimfw 比 oh my zsh 更轻量,适合管理 zsh plugin。现在主方案是
Starship + zoxide + fzf:Starship 交给 zimfw module 做缓存和编译优化,zoxide、fzf 和 alias
放到 统一 zsh 配置 里处理,fnm、venv function 这类环境集成按需追加,
powerlevel10k 只作为备份方案保留。
安装 zsh 和基础工具
Debian / Ubuntu
sudo apt install -y zsh git curl chroma fzf
chsh -s "$(command -v zsh)"zoxide 可以用官方安装脚本安装到 ~/.local/bin。
curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh如果已经用 nix profile 管理用户态工具,也可以直接用 nix 安装。
nix profile add nixpkgs#zoxide如果 ~/.local/bin 没有在 PATH 里,先加到 ~/.zshrc。
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrcmacOS
brew install zsh git curl chroma fzf zoxide
chsh -s "$(command -v zsh)"Starship binary 的安装和 starship.toml 配置看 Starship 配置。
安装 zimfw
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zshZim install 会生成一批默认 module,例如 environment、git、input、termtitle、
utility、zsh-completions、completion、zsh-syntax-highlighting、
zsh-history-substring-search、zsh-autosuggestions。这些默认配置保留即可,不要重复追加。
只把自己额外需要的 module 放到 ~/.zimrc 末尾。
cat <<'EOF' >> ~/.zimrc
zmodule joke/zim-starship
zmodule romkatv/zsh-defer
EOF
zimfw install注意不要在 ~/.zimrc 里同时加载 powerlevel10k、asciiship、zimfw 自带 theme 或其他 prompt /
theme module。joke/zim-starship 会初始化 Starship,所以不要再在 ~/.zshrc 里写
eval "$(starship init zsh)"。
zoxide 不放到 zimfw module 里,统一在 .zshrc 里用 zsh-defer 不延时异步初始化,避免给
prompt 首屏加同步成本。
zimfw/ssh 会在 shell 启动时尝试维护 ~/.ssh-agent 并执行 ssh-add,容易把次级功能放进
首屏路径。速度优先时不默认加载这个 module;需要时再手动启动 ssh-agent 或交给系统/桌面环境。
如果更想要 zoxide init script 的 cache / zcompile,可以改用 antoineco/zim-zoxide。这种
方式仍然会同步 source 缓存文件;启用后要删除 .zshrc 里的 zoxide init zsh,避免重复初始化。
如果使用 Zim install 默认生成的 .zimrc,还要确认 Prompt 这一段保持注释状态。
asciiship 是 prompt 本体,duration-info 和 git-info 是给 asciiship 用的辅助信息。
使用 Starship 时不要打开它们。
# Exposes to prompts how long the last command took to execute, used by asciiship.
#zmodule duration-info
# Exposes git repository status information to prompts, used by asciiship.
#zmodule git-info
# A heavily reduced, ASCII-only version of the Spaceship and Starship prompts.
#zmodule asciiship配置 zsh
通用 .zshrc 放在 统一 zsh 配置。默认只启用 zoxide、fzf 和 alias;
fnm、venv function、WSL PATH 清理等按需追加对应插槽。
统一配置会检测 ~/.zimrc 是否启用了 joke/zim-starship,已启用时不会重复执行 starship init。
如果之前用过 autojump,可以把历史数据导入 zoxide。
zoxide import --from=autojump ~/.local/share/autojump/autojump.txt备份方案:Powerlevel10k
如果要临时回退到 p10k,只保留一个 prompt。启用 p10k 时,把 ~/.zimrc 里的
zmodule joke/zim-starship 注释掉;切回 Starship 时,再从 ~/.zimrc 移除或注释
zmodule romkatv/powerlevel10k。
cat <<'EOF' >> ~/.zimrc
zmodule romkatv/powerlevel10k
EOF
zimfw install
p10k configure