Mac OS 配置终端神器 oh-my-zsh

发布时间 2023-06-01 00:00:15作者: little_lunatic

1.安装zsh、git

brew update

brew install zsh 
  • 踩坑点:brew update 报错

  • 解决方法:

cd /opt/homebrew/Library/Taps/homebrew/homebrew-services/

git remote -v

git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-services

2.设置默认终端

#查看当前shell
echo $SHELL

#查看安装的shells
cat /etc/shells

#切换shell
chsh -s /bin/zsh

3.安装oh-my-zsh

#安装wget
brew install libunistring
brew install openssl@1.1
brew install wget

#安装oh-my-zsh
cd ~
wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh
rm -rf install.sh

4.配置oh-my-zsh

#下载高亮插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

#下载自动补全插件
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

#下载字体,挨个下载安装
https://github.com/romkatv/powerlevel10k/blob/master/font.md
#终端设置字体:command + ,

#下载主题
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k

#写入.zshrc配置文件
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
echo 'plugins=(zsh-syntax-highlighting zsh-autosuggestions)' >>~/.zshrc

#刷新生效
source ~/.zshrc

使用默认配置就行,不用去自定义了,上效果图: