Wsl-终端美化

使用到的是oh-my-zsh
感觉这个上手还是比较快的。
参考的教程:
使用 Oh My Zsh 主题和插件自定义您的终端
zsh 安装与配置,使用 oh-my-zsh 美化终端 | Leehow的小站
主题预览:
oh-my-zsh 主题样式列表 | 计算机科学论坛
官网:(也有安装教程)
Oh My Zsh - a delightful & open source framework for Zsh

安装主题前,需要安装 ZSH

1
sudo apt install zsh

验证安装结果:

1
2
~# zsh -v
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)

将其设置为默认shell(注意不要使用sudo)

1
chsh -s $(which zsh)

接着开始安装oh my zsh
任选一个进行安装:

Method Command
curl sh -c "$(curl -fsSL https://install.ohmyz.sh/)"
wget sh -c "$(wget -O- https://install.ohmyz.sh/)"
fetch sh -c "$(fetch -o - https://install.ohmyz.sh/)"
国内curl镜像 sh -c "$(curl -fsSL https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"
国内wget镜像 sh -c "$(wget -O- https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"

安装好之后我们可以加入一些插件

添加插件的方法:

  • 手动安装
  • 将插件名添加到 .zshrc
1
plugins=(git plugin-name)

插件配置和更新

1
cd ~/.oh-my-zsh/custom/plugins/plugin-name git pull

对于内置插件,使用oh my zsh的更新机制:

1
omz update

如果您的 shell 变慢,监控插件加载时间:

1
2
3
4
5
6
7
8
time zsh -i -c exit
```
如果启动时间超过 1-2 秒,考虑删除未使用的插件或切换到更轻量的替代方案。

**zsh-autosuggestions** 基于您的历史记录提供智能命令补全。当您输入时,它以灰色文本建议命令。按右箭头键接受建议。

安装它:

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

1
2
3
4
5

**zsh-syntax-highlighting** 在您输入时为命令着色,使发现拼写错误和理解命令结构更容易。

安装它:

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

1
2
3
4
5
6
7
8



# 自定义主题
### 自定义主题创建

通过复制现有主题创建自定义主题:

cp ~/.oh-my-zsh/themes/robbyrussell.zsh-theme ~/.oh-my-zsh/custom/themes/mytheme.zsh-theme

1
2
3

编辑主题文件以自定义颜色、布局和信息显示。基本主题结构:

PROMPT=’%{$fg[cyan]%}%n%{$reset_color%}:%{$fg[green]%}%c%{$reset_color%}$(git_prompt_info) %# ‘
ZSH_THEME_GIT_PROMPT_PREFIX=” git:(%{$fg[red]%}”
ZSH_THEME_GIT_PROMPT_SUFFIX=”%{$reset_color%}”
ZSH_THEME_GIT_PROMPT_DIRTY=”%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}”
ZSH_THEME_GIT_PROMPT_CLEAN=”%{$fg[blue]%})”

1
2
3

设置您的自定义主题:

ZSH_THEME=”mytheme”



Wsl-终端美化
https://pqcu77.github.io/2025/11/09/wsl-终端美化/
作者
linqt
发布于
2025年11月9日
许可协议