mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4mobile wallpaper 5mobile wallpaper 6
327 words
1 minute
Zsh & Powerlevel10k Setup
2024-12-01

安装环境#

首先安装 Zsh 作为默认 Shell,同时安装 Git 和 Curl,后续用于 Oh My Zsh 的安装与美化。

sudo dnf install -y zsh git curl

将默认 Shell 切换为 Zsh:

chsh -s /bin/zsh

接着安装 Oh My Zsh,任选以下一种方式即可。若下载缓慢,请考虑使用代理或镜像源:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

配置 Powerlevel10k#

Powerlevel10k 是一款热门的 Oh My Zsh 主题,配置选项丰富,既简洁又美观。

romkatv
/
powerlevel10k
Waiting for api.github.com...
00K
0K
0K
Waiting...

使用以下命令进行安装:

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

再安装两个常用插件:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

然后编辑当前用户的 Zsh 配置文件 ~/.zshrc,找到 ZSH_THEMEplugins 两项,修改为如下内容:

ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

此时主题本身已配置完成,但要想获得完整体验,还需要安装一款合适的字体。

推荐使用 Nerd Font,从官网下载喜欢的字体后,根据系统类型进行安装,最后在终端设置中启用该字体即可。以下为 VS Code 中的字体配置示例:

{
"terminal.integrated.fontFamily": "'0xProto Nerd Font', monospace",
"editor.fontFamily": "'Droid Sans Mono', monospace",
"workbench.colorTheme": "One Dark Pro"
}

重新打开终端,即可看到 Powerlevel10k 的初始化配置向导。如果图标显示异常或配置出错,可按 Ctrl+C 退出向导,下次启动终端时会再次进入。

若想重新运行配置向导,执行:

p10k configure
Share

If this article helped you, please share it with others!

Zsh & Powerlevel10k Setup
https://blog.yremmmm.com/posts/zsh/
Author
why?
Published at
2024-12-01
License
CC BY-NC-SA 4.0

Some information may be outdated

Cover
Sample Song
Sample Artist
Cover
Sample Song
Sample Artist
0:00 / 0:00