1. 安装 oh-my-zsh
git clone <https://github.com/ohmyzsh/ohmyzsh.git> ~/.oh-my-zsh
2. 确认本体文件存在
ls -l ~/.oh-my-zsh/oh-my-zsh.sh
3. 建主题目录
mkdir -p ~/.oh-my-zsh/custom/themes
4. 下载你的主题
curl -L <https://cdn.haoyep.com/gh/leegical/Blog_img/zsh/haoomz.zsh-theme> -o ~/.oh-my-zsh/custom/themes/haoomz.zsh-theme
5. 写入最小可用配置
cat > ~/.zshrc <<'EOF'
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="haoomz"
plugins=(git)
source $ZSH/oh-my-zsh.sh
EOF
6. 生效
source ~/.zshrc
7. 删除主机前缀
打开你的主题文件:
nano ~/.oh-my-zsh/custom/themes/haoomz.zsh-theme
然后找里面的 PROMPT= 或 RPROMPT= 相关内容。
如果你看到类似这种:
%n@%m
或者
%n@%M
把这一段删掉就行。
举个例子
如果原来是:
PROMPT='%n@%m %~ %# '
你就改成:
PROMPT='%~ %# '
改完让它生效
source ~/.zshrc
8. 插件安装
Mac 开发常用版
plugins=(
git
sudo
extract
z
colored-man-pages
brew
copypath
copyfile
)
自动补全加代码高亮
1.安装自动建议
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
2.安装语法高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
3.安装增强补全
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions
~/.zshrc 怎么配
plugins=(
git
sudo
extract
z
colored-man-pages
copypath
copyfile
brew
zsh-autosuggestions
zsh-completions
zsh-syntax-highlighting
)
让配置生效
source ~/.zshrc