美化你的终端——zsh 和 on-my-zsh
约 366 个字
32 行代码
预计阅读时间 2 分钟
日常里用aliyun cloud linux 和 ubuntu 两个发行版比较多,但是都不是很喜欢他们 bash 的风格,简而言之:
不够花里胡哨(划掉
因为装的次数比较多了,为了方便之后还要装,我直接写个文档算了(写文档真的很累啦
下载zsh
我们先要下载必要的软件和工具。
设置默认终端为zsh。
这时候我们默认启动的终端就是zsh了,但是当前的shell不会立即切换,如果想要直接使用zsh,可以重新登录。但是我们要使用oh-my-zsh对终端进行美化,所以我们最好先在当前bash下先把oh-my-zsh装了。
下载oh-my-zsh
我们先下载oh-my-zsh的文件。
如果已经在原先的 bash 中设置了一些自定义别名或其他自定义配置,需要将.bashrc
内的配置项手动迁移至.zshrc
。
设置主题——王朝了powerlevel10k大人
根据大家伙的评价,powerlevel10k是当之无愧的 oh-my-zsh 最强主题,无需多言,直接入手!
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
# github上不去?gitee.com 上的官方镜像加速下载
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
进入.zshrc
设置ZSH_THEME=powerlevel10k/powerlevel10k
,然后重新加载它,终端将自动引导你完成 powerlevel10k 的配置。
安装插件
我喜欢这几个插件:zsh-autosuggestions、zsh-syntax-highlighting、extract,分别提供了命令提示,命令校验和方便解压的功能,其中前两个需要下载。
# 下载zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 国内镜像加速
git clone https://gh.xmly.dev/https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 下载zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 国内镜像加速
git clone https://gh.xmly.dev/https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
启用插件,修改.zshrc
中的plugin内容。