Featured image of post oh-my-zsh的安装与配置

oh-my-zsh的安装与配置

为你的终端配置一个更好用的shell

为你的终端配置一个更好用的shell

# 安装前置

1
sudo apt install zsh git curl wget vim -y

# 安装oh-my-zsh

1
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

或者

1
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# 安装插件

# 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

# z

目录跳转插件,可以根据历史访问频率跳转到指定目录,oh-my-zsh自带

# 使用插件

# 打开配置文件

1
vim ~/.zshrc

# 修改配置

找到plugins行,添加插件名

1
2
3
4
5
6
7
plugins=(
    ... # 其他插件
    git
    zsh-autosuggestions
    zsh-syntax-highlighting
    z
)

# 修改主题

具体主题可以在这里查看

也可安装p10k主题

1
ZSH_THEME="random" # 随机主题

# 使配置生效

1
source ~/.zshrc

使用 Hugo 构建
主题 StackJimmy 设计