使用 oh my zsh 配置 zsh
oh my zsh 这里只做备份,不确保时效性。我个人现在主方案是 zimfw + Starship + zoxide + fzf:
oh my zsh/zimfw 负责 plugin,Starship 负责 prompt,zoxide 替代 autojump,fzf 提供模糊搜索。
安装 zsh 和 oh my 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)"安装 oh my zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"Starship 的安装和 starship.toml 配置看 Starship 配置。
获取 zsh 插件
git clone https://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions --depth=1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting --depth=1
git clone https://github.com/romkatv/zsh-defer.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-defer --depth=1配置 zsh
编辑 ~/.zshrc,把 oh my zsh 自带主题关掉,并启用常用插件。这里只保留 Starship 一个
prompt,避免和 robbyrussell、p10k 或其他 prompt 初始化冲突。
ZSH_THEME=""
plugins=(git docker colorize zsh-defer zsh-autosuggestions zsh-syntax-highlighting)继续把 zoxide、fzf 的异步初始化和自用 alias 放到 统一 zsh 配置。
fnm、venv function 等按需追加对应插槽。oh my zsh 没有 joke/zim-starship 这类 zimfw module,
统一配置会自动执行 Starship 初始化。
如果之前用过 autojump,可以把历史数据导入 zoxide。
zoxide import --from=autojump ~/.local/share/autojump/autojump.txt备份方案:Powerlevel10k
如果要临时回退到 p10k,只保留一个 prompt。启用 p10k 时,把统一 zsh 配置里的
eval "$(starship init zsh)" 注释掉。
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k编辑 ~/.zshrc,把主题改成 p10k。
ZSH_THEME="powerlevel10k/powerlevel10k"
p10k configureLast updated on