@一、安装
- @Tips:未安装git或zsh时请先安装
- @使用国内镜像下载
@二、配置主题以及安装常用插件
@配置文件~/.zshrc
@主题,此处我的主题已经更改,一般默认为robbyrussell
@安装常用插件
- @2.1 oh-my-zsh内置自动补全
- @2.2 zsh-completions:额外补全
- @2.3 zsh-autosuggestions:历史补全
- @2.4 Incremental completion on zsh:实时补全
- @2.5 zsh-syntax-highlighting:语法高亮
@三、总结
一、安装
Tips:未安装git或zsh时请先安装
Centos7安装方式,yum一般自带,如果没有安装请自行百度
其他版本Linux对应安装方式请自行百度
#安装git
yum install git
#安装zsh
yum install zsh
使用国内镜像下载
sh -c "$(curl -fsSL https://gitee.com/shmhlsy/oh-my-zsh-install.sh/raw/master/install.sh)"
二、配置主题以及安装常用插件
配置文件~/.zshrc
vi ~/.zshrc #打开配置文件
主题,此处我的主题已经更改,一般默认为robbyrussell
- GitHub上的wiki地址:https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
安装常用插件
- git是默认开启的
2.1 oh-my-zsh内置自动补全
- 自动列出目录:输入 cd 按 tab 键,将列出所有目录,再按 tab 可以切换。
- 自动补全目录:例如 /usr/local/share 这个长路径,只需要 cd /u/l/s 按 tab 键自动补全
2.2 zsh-completions:额外补全
git clone --depth=1 https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions
fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
source "$ZSH/oh-my-zsh.sh"
2.3 zsh-autosuggestions:历史补全
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-autosuggestions
#在~/.zshrc中补充配置,其他插件也是同理
2.4 Incremental completion on zsh:实时补全
mkdir $ZSH_CUSTOM/plugins/incremental
curl -fsSL https://mimosa-pudica.net/src/incr-0.2.zsh -o $ZSH_CUSTOM/plugins/incremental/incr.zsh
echo 'source $ZSH_CUSTOM/plugins/incremental/incr.zsh' >> ~/.zshrc
source ~/.zshrc
2.5 zsh-syntax-highlighting:语法高亮
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
三、总结
- 自行安装的插件都在目录~/.oh-my-zsh/custom/plugins内部,当联网不便时或已有完整包可直接上传到对应的目录下,然后修改~/.zshrc配置文件的plugins,修改完成后使用source ~/.zshrc使得配置生效
- 若出现环境变量失效,将~/.bash_profile添加到zsh配置文件即可,即source ~/.bash_profile 添加到~/.zshrc文件底部即可