centos7 安装zsh和oh-my-zsh
查看当前shell
| 1 | echo $SHELL | 
查看当前服务器所有 shell
| 1 | cat /etc/shells | 
安装zsh
| 1 | yum -y install zsh | 
查看是否已有 zsh
| 1 | cat /etc/shells | grep zsh | 
将 zsh 设置成默认的 shell
| 1 | chsh -s /bin/zsh | 
设置完以后不会立即生效,需要重启方能生效。我们可以配置完 oh-my-zsh 以后再重启。
安装oh-my-zsh
| 1 | wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh | 
配置主题
修改配置文件
| 1 | vim ~/.zshrc | 
修改 ZSH_THEME 为你喜欢的主题,例如我用的 agnoster
| 1 | # ZSH_THEME="robbyrussell" | 

保存,并更新配置文件
| 1 | source ~/.zshrc | 
新开一个终端即可使用 zsh

oh-my-zsh 插件
打开 ~/.zshrc 文件,编辑 plugins=,在后面写入需要的插件名(有些插件可能需要手动安装)
zsh-autosuggestion
输入命令时可提示自动补全(灰色部分),然后按键盘 → (方向键右键,不是tab键)即可补全
- 安装
| 1 | git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions | 
- 编辑 ~/.zshrc添加到plugins=
| 1 | ... | 
- 重载配置文件
| 1 | source ~/.zshrc | 
zsh-syntax-highlighting
日常用的命令会高亮显示,命令错误显示红色
- 安装 - shell - 1 - git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting 
- 编辑 - ~/.zshrc添加到- plugins=- ~/.zshrc - 1 
 2
 3
 4
 5
 6
 7- ... 
 plugins=(
 git
 zsh-autosuggestions
 zsh-syntax-highlighting
 )
 ...
- 重载配置文件 - shell - 1 - source ~/.zshrc 
autojump
功能:实现目录间快速跳转,想去哪个目录直接 j + 目录名,不用在频繁的 cd 了! github地址。
history | grep "git clone"这个命令就能找到近期 clone 了哪些库,省却了写一堆代码的功夫。
autojump 就是通过记录你在 history 中的行为把你访问过的文件夹路径都 cache 下来,当你输入路径名的时候会模糊匹配你之前cd过的目录路径
- 克隆代码 - shell - 1 - git clone git://github.com/joelthelion/autojump.git 
- 安装 - shell - 1 
 2- cd autojump 
 ./install.py
- 编辑 - ~/.zshrc添加到- plugins=- ~/.zshrc - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10- ... 
 plugins=(
 git
 zsh-autosuggestions
 zsh-syntax-highlighting
 autojump
 )
 ...
 # 在文件末尾添加
 -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
- 重载配置文件 - shell - 1 - source ~/.zshrc 
参考文章:
- 本文标题:centos7 安装zsh和oh-my-zsh
- 本文作者:akiya
- 本文链接:https://little-star.love/posts/71151cd9/
- 版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!







