Oh My Zsh 手动安装与配置指南

Oh My Zsh 手动安装与配置指南(普通用户+ root 用户)

概念:

  • zsh:Shell 本体(类似 bash)
  • Oh My Zsh(OMZ):基于 zsh 的配置与插件管理框架
  • 插件:功能扩展(高亮、自动建议等)
  • 主题:提示符样式(prompt)

一、安装 zsh(Shell 本体)

1
sudo pacman -S zsh
1
zsh --version

设置为默认 shell(普通用户):

1
chsh -s $(which zsh)

重启系统后生效

二、手动安装 Oh My Zsh(不使用官方脚本)

1. 安装 git
1
sudo pacman -S git
2. 克隆 OMZ 仓库
1
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
3. 生成基础 .zshrc
1
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
4、.zshrc 标准结构(一般都是这样子的)
1
2
3
4
5
6
7
8
export ZSH="$HOME/.oh-my-zsh"

ZSH_THEME="robbyrussell"

plugins=(git)

# 加载 Oh My Zsh(必须靠后)
source $ZSH/oh-my-zsh.sh

三、配置

1、更改主题
1
vim ~/.zshrc

[!IMPORTANT]

robbyrussell:更换你喜欢主题名字,在下面链接查看

1
https://github.com/ohmyzsh/ohmyzsh/wiki/themes

链接中的主题都已经内置在了:~/.oh-my-zsh/themes/ 目录中

1
ZSH_THEME="robbyrussell"
2、添加插件

[!IMPORTANT]

推荐两个插件:

自动补全:zsh-autosuggestions

代码高亮:zsh-syntax-highlighting

使用 git 拉去即可

1
git clone 

将其放在 ~/.oh-my-zsh/plugins/ 目录下

1
vim ~/.zshrc
1
2
3
4
5
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)

最后 source ~/.zshrc 或者 重启终端 即可使用

以上是普通用户配置


四、root 用户配置(不推荐)

1、安装 zsh(Shell 本体)

前面已经安装则跳过

1
sudo pacman -S zsh
1
zsh --version

在 root 下设置为默认 shell(root 用户):

1
chsh -s $(which zsh)

重启系统后生效

2、在 root 下“重新安装” Oh My Zsh(手动方式)
1
git clone https://github.com/ohmyzsh/ohmyzsh.git /root/.oh-my-zsh
1
cp /root/.oh-my-zsh/templates/zshrc.zsh-template /root/.zshrc
3、使用 Pacman 安装插件
1
sudo pacman -S zsh-autosuggestions zsh-syntax-highlighting

插件路径:

1
/usr/share/zsh/plugins/
4、在 .zshrc 中启用(主题更改也是跟上面一样的)
1
2
3
4
5
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)

最后 source ~/.zshrc 或者 重启终端 即可使用


Oh My Zsh 手动安装与配置指南
https://huishao.fun/Oh-My-Zsh-Arch/
作者
huishao
发布于
2026年1月3日
许可协议