Archlinux zsh终端美化 powerlevel10k配置
阅读原文时间:2023年07月08日阅读:1

环境

Arch Linux + KDE Plasma

安装zsh

yay -S zsh


chsh -s /bin/zsh

安装oh-my-zsh-git

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

yay -S oh-my-zsh-git


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

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

安装插件

yay -S autojump


yay -S zsh-syntax-highlighting zsh-autosuggestions

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

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

plugins=(
    sudo
    git
    autojump
    zsh-syntax-highlighting
    zsh-autosuggestions
)

安装powerlevel10k样式

下载字体

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

缓存字体

fc-cache -vf ~/.local/share/fonts/

查看是否安装成功

fc-list | grep -i droid
/home/kylin/.local/share/fonts/Droid Sans Mono for Powerline Nerd Font Complete.otf: DroidSansMonoForPowerline Nerd Font:style=Book

设置终端字体

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


ZSH_THEME="powerlevel10k/powerlevel10k"

source ~/.zshrc

重启终端即可进入配置p10k

**p10k configure 以直接从终端访问内置配置向导 **

注意事项

Instant Prompt Mode 选择off