
Oh My Zsh 安装与配置
2023年11月6日...大约 3 分钟
Zsh 是 Shell 的一种,它是 Bash 的升级版,提供了更多的功能,比如自动补全、语法高亮、命令别名等等。而 Oh My Zsh 是 Zsh 的一个扩展,提供了更多的主题和插件,可以让我们更加方便的使用 Zsh。
安装 Zsh
sudo apt install zsh安装完成后,查看系统中可用的 Shell
cat /etc/shells将 zsh 设置为系统默认 Shell
chsh -s /bin/zsh安装 Oh My Zsh

::: code-tabs#shell
@tab curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"@tab wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"@tab fetch
sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)":::
配置 Oh My Zsh
Oh My Zsh 的配置文件在 ~/.zshrc 中,我们可以在这个文件中修改主题、插件等配置。
vim ~/.zshrc # 编辑配置文件
# 编辑完成后,执行以下命令使配置文件生效
source ~/.zshrc # 使配置文件生效主题
官方主题已经集成在 Oh My Zsh 中,我们只需要在配置文件中修改 ZSH_THEME 的值即可。
ZSH_THEME="robbyrussell"安装方法
- Clone the repository:
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10kUsers in China can use the official mirror on gitee.com for faster download. 中国用户可以使用 gitee.com 上的官方镜像加速下载.
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k- Set
ZSH_THEME="powerlevel10k/powerlevel10k"in~/.zshrc.
插件
官方插件同样已经集成在 Oh My Zsh 中,我们只需要在配置文件中修改 plugins 的值即可,格式如下。
plugins=(
git
yarn
npm
emoji
pip
)第三方插件推荐
- zsh-autosuggestions 自动补全插件
- 使用
git将插件下载到本地$ZSH_CUSTOM/plugins目录 (默认安装目录为~/.oh-my-zsh/custom/plugins)
- 使用
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions2. 下载完成后在`~/.zshrc`中添加插件
plugins=(
# other plugins...
zsh-autosuggestions
)- zsh-syntax-highlighting 语法高亮插件
- 使用
git将插件下载到本地$ZSH_CUSTOM/plugins目录 (默认安装目录为~/.oh-my-zsh/custom/plugins)
- 使用
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting2. 下载完成后在 `~/.zshrc` 中添加插件
plugins=(
# other plugins...
zsh-autosuggestions
zsh-syntax-highlighting
)- z 文件目录跳转插件
z是 oh-my-zsh 自带的插件,无需额外安装,直接在配置文件中添加即可
plugins=(
# other plugins...
z
)项目地址
更新日志
2025/10/10 04:22
查看所有更新日志
894f6-于ee79c-于0465c-于e2212-于721e4-于b9134-于d7869-于90edf-于6a9ae-于

预览: