
传统的 bash 功能比较简陋,且不美观。本文基于 Ubuntu22.04 LTS 系统,安装 zsh,并使用 oh-my-zsh 对终端进行美化。Oh My Zsh 是基于 zsh 命令行的一个扩展工具集,提供了丰富的扩展功能。
设置默认终端为 zsh(注意:不要使用 sudo)。
chsh -s /bin/zsh官网:http://ohmyz.sh/。 安装方式任选一个即可。
| 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)" |
注意:同意使用 Oh-my-zsh 的配置模板覆盖已有的 .zshrc。

.bashrc中迁移配置(可选)如果之前在使用bash时自定义了一些环境变量、别名等,那么在切换到zsh后,你需要手动迁移这些自定义配置。
# 查看bash配置文件,并手动复制自定义配置
cat ~/.bashrc
# 编辑zsh配置文件,并粘贴自定义配置
nano ~/.zshrc
# 启动新的zsh配置
source ~/.zshrcroot用户在执行sudo su命令后,再运行上述代码查看、手动复制、粘贴自定义配置。