效果图:
一:安装oh-my-zsh,官方有两种方式
# via curl
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# via wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
如果不行,在 👉oh-my-zsh GitHub 上下载,mac上默认就是下载到Download
cd ~/Downloads
mv ohmyzsh-master ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
source ~/.zshrc
重启终端之后之后,打开 👉https://github.com/ohmyzsh/ohmyzsh/wiki/Themes 更为直观的查看所有的配色方案
1、接下来修改主题
vim ~/.zchrc
修改ZSH_THEME的值
保存退出
source ~/.zshrc
2、然后需要打开 ~/.zshrc
设置 ZSH_THEME
:
ZSH_THEME="powerlevel10k/powerlevel10k"
二、#配置Brew(后面可能用得到,已经安装的可不看)
运行下面自动脚本(已经全部替换为国内地址):
(Mac)常规安装脚本(推荐完全体几分钟安装完成)
/bin/zsh -c
"$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
(Mac)精简版几秒钟安装完成
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" speed
(Mac)卸载脚本
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
(Linux)安装脚本:
rm Homebrew.sh ; wget https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh ; bash Homebrew.sh
(Linux)卸载脚本:
rm HomebrewUninstall.sh ; wget https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh ; bash HomebrewUninstall.sh
安装问题
如果发现有各种安装不上的运行:
sudo rm -rf /usr/local/Homebrew
提示系统太旧的 (Failed to install Homebrew Portable Ruby (and your system version is too old)!) 运行:
HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles-portable-ruby
rm -rf /Users/$(whoami)/Library/Caches/Homebrew/
brew update
配置环境变量
vim ~/.bash_profile
在最后一行添加
export PATH=$PATH:/opt/homebrew/bin;
保存退出执行
source ~/.bash_profile
三、安装插件
1、安装插件-高亮插件highlighting
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
vi ~/.zshrc
这时我们再次打开zshrc文件进行编辑。找到plugins,此时plugins中应该已经有了git,我们需要把高亮插件也加上:
请务必保证插件顺序,zsh-syntax-highlighting必须在最后一个。
然后在文件的最后一行添加:
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
执行:
source ~/.zshrc
2、安装插件-命令补全zsh-autosuggestion,用于命令建议和补全
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-autosuggestions
vi ~/.zshrc
找到plugins,加上这个插件即可:
参考文档: