环境

Arch Linux + KDE Plasma

安装 zsh

1
yay -S zsh

更改默认终端

1
chsh -s /bin/zsh

安装 oh-my-zsh-git

archlinuxcn 源有打好的包,或者使用 AUR 安装。

1
yay -S oh-my-zsh-git

默认配置

1
cp /usr/share/oh-my-zsh/zshrc ~/.zshrc

这时候打开终端软件,应该就会默认进入 zsh 了

安装插件

autojump 跳转目录

1
yay -S autojump

命令高亮现和自动建议补全

1
yay -S zsh-syntax-highlighting zsh-autosuggestions

这两个是 zsh 插件,使用上面的方式配置是不行的,因为 oh-my-zsh 找不到这两个插件(会报 plugin not found)。为此我们要进行一下特殊处理,创建这两个插件的符号链接到 oh-my-zsh 的自定义插件目录

1
2
sudo ln -s /usr/share/zsh/plugins/zsh-syntax-highlighting /usr/share/oh-my-zsh/custom/plugins/
sudo ln -s /usr/share/zsh/plugins/zsh-autosuggestions /usr/share/oh-my-zsh/custom/plugins/

插件配置

同样是打开.zshrc 文件,找到 plugins=(git),在这里增加自己想要的插件即可,多个插件名称之间使用空格或者换行分开(不能使用逗号)。
vim ~/.zshrc

1
2
3
4
5
6
7
plugins=(
sudo
git
autojump
zsh-syntax-highlighting
zsh-autosuggestions
)
1
source .zshrc

安装 powerlevel10k 样式

安装 Nerd Fonts 字体

下载字体

1
2
mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts && curl -fLo "Droid Sans Mono for Powerline Nerd Font Complete.otf" https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete/Droid%20Sans%20Mono%20Nerd%20Font%20Complete.otf

查看是否安装成功

1
fc-list | grep -i droid

image

设置终端字体

image

下载 powerlevel10k

1
sudo git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k

修改 zsh 主题

1
2
3
ZSH_THEME="powerlevel10k/powerlevel10k"

source ~/.zshrc

重启终端即可进入配置 p10k
**p10k configure 以直接从终端访问内置配置向导 **

image

注意事项

配置成功后只显示一行

Instant Prompt Mode 选择 off