当前位置: 首页 > 工具软件 > Oh My Zsh > 使用案例 >

oh-my-zsh安装

桑博远
2023-12-01

介绍

Oh My Zsh是一款很棒的shell环境,它的界面很漂亮,而且插件很多,可以很大程度提升终端使用效率

安装过程

1. 安装zsh

由于oh-my-zsh是基于zsh的,因此需要先安装zsh

yum install -y zsh  # CentOS
sudo apt install -y zsh # Ubuntu

2. 安装Oh-My-Zsh

打开官网首页,即可看到安装脚本:

Oh My Zsh

# 使用curl安装
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

# 使用wget安装
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

一般情况按照如上脚本安装后当前用户shell会自动转换成zsh,如果遇到shell没有自动转换的时候需要手动修改/etc/passwd文件,将当前用户的默认shell修改为zsh

3. 安装额外插件

3.1 下载插件

此处需要确定变量**${ZSH_CUSTOM:-~/.oh-my-zsh/custom}**是否已经设置,如果没有设置则需要将其手动替换成对应目录

# 自动语法高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# 在输入命令时会给出建议的命令
git clone git://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# 打开git的远程仓库[这个插件在桌面端建议安装,在服务器端不要安装]
git clone https://github.com/paulirish/git-open.git $ZSH_CUSTOM/plugins/git-open

3.2 配置插件

vim ~/.zshrc

在~/.zshrc文件中添加插件配置信息

plugins=(其他的插件 zsh-syntax-highlighting zsh-autosuggestions git-open)

3.3 使得配置生效

source ~/.zshrc
 类似资料: