详细步骤
1、安装zsh,并切换默认使用zsh
sudo apt install zsh -y
chsh -s $(which zsh)
执行完成后,关闭终端,重新打开,并使用以下命令确认已经切换成功。
echo $SHELL
2、使用国内源下载oh my zsh
wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
3、下载之后给install.sh添加执行权限:
chmod +x install.sh
4、使用vim打开install.sh文件(vim install.sh)后,找到以下部分:
ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}
将中间两行修改为下面这样,使用gitee镜像:
REPO=${REPO:-mirrors/ohmyzsh}
REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}
然后安装
./install.sh
5、安装插件和主题
# powerlevel10k主题
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
# zsh-autosuggestions自动提示插件
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# zsh-syntax-highlighting语法高亮插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 配置powerlevel10k
p10k configure
加速镜像:
https://gitclone.com/
6、编辑~/.zshrc
文件启用插件和主题
# 修改主题
ZSH_THEME="powerlevel10k/powerlevel10k"
# 启用插件
plugins=(
z
git
zsh-autosuggestions
zsh-syntax-highlighting
)
7、重新加载~/.zshrc
source ~/.zshrc
8、按照界面进行配置。
9、如果有乱码,请安装以下字体:
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf &&
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf &&
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf &&
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
在终端中设置字体为MesloLGS NF
即可。