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 | ~# zsh -v |
将其设置为默认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 | time zsh -i -c exit |
如果启动时间超过 1-2 秒,考虑删除未使用的插件或切换到更轻量的替代方案。
zsh-autosuggestions 基于您的历史记录提供智能命令补全。当您输入时,它以灰色文本建议命令。按右箭头键接受建议。
安装它:
1 | git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions |
zsh-syntax-highlighting 在您输入时为命令着色,使发现拼写错误和理解命令结构更容易。
安装它:
1 | git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting |
自定义主题
自定义主题创建
通过复制现有主题创建自定义主题:
1 | cp ~/.oh-my-zsh/themes/robbyrussell.zsh-theme ~/.oh-my-zsh/custom/themes/mytheme.zsh-theme |
编辑主题文件以自定义颜色、布局和信息显示。基本主题结构:
1 | PROMPT='%{$fg[cyan]%}%n%{$reset_color%}:%{$fg[green]%}%c%{$reset_color%}$(git_prompt_info) %# ' |
设置您的自定义主题:
1 | ZSH_THEME="mytheme" |