Zsh 官网 :
https://www.zsh.org/
oh-my-Zsh 官网 :
http://ohmyz.sh/
Zsh 和 oh-my-Zsh 的关系
Zsh 是 Shell 中的一种,什么 Shell 你可以再搜索下,简单粗暴讲就是一个:命令解释器,你输入什么命令,它就执行什么,这个东西再 Unix 世界还有其他几个。由于 Zsh 配置门槛有点高,或者说需要专门花时间去了解 Zsh 才能配置好一个好用的 Zsh,也因为这样,用户也就相对少了。直到有一天 oh-my-Zsh 的作者诞生,他想要整理出一个配置框架出来,让大家直接使用他的这个公认最好的 Zsh 配置,省去繁琐的配置过程。所以,oh-my-Zsh 就诞生了,它只是会了让你减少 Zsh 的配置,然后又可以好好享受 Zsh 这个 Shell
Mac
查看 Mac 中支持终端
$ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
默认情况下 Mac 已经安装 Zsh,如果没有可以手动安装 :
$ brew install Zsh
装了 zsh 之后,修改终端配置就变成 :
vim ~/.zshrc ,而不是 :
vim ~/.bash_profile ,所以以后看到别人的文章中需要 :
vim ~/.bash_profile ,需要变通思想过来
同时更新修改后的配置文件也从 :
source ~/.bash_profile ,变成 :
source ~/.zshrc ,当然还有其他取巧方式,这里不谈
Linux 环境下的 Zsh 配置
Linux 中安装 Zsh
$ echo $SHELL # 查看当前系统的 shell
/bin/bash
# yum install zsh
# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/zsh
# chsh -s /bin/zsh # 切换 zsh
# reboot # 重启生效
# echo $SHELL # 重启后检查是否使用 zsh
/bin/zsh
安装 oh-my-Zsh 套件
# 需要从 GitHub 上下载脚本因此需要安装 git
# yum install git
--2018-03-17 12:14:55-- https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh
正在解析主机 github.com (github.com)... 192.30.253.112, 192.30.253.113
正在连接 github.com (github.com)|192.30.253.112|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
--2018-03-17 12:15:27-- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
正在解析主机 raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
正在连接 raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:4019 (3.9K) [text/plain]
正在保存至: “STDOUT”
100%[======================================>] 4,019 --.-K/s 用时 0s
2018-03-17 12:15:38 (75.2 MB/s) - 已写入至标准输出 [4019/4019]
Cloning Oh My Zsh...
正克隆到 '/root/.oh-my-zsh'...
remote: Counting objects: 852, done.
remote: Compressing objects: 100% (716/716), done.
remote: Total 852 (delta 16), reused 787 (delta 10), pack-reused 0
接收对象中: 100% (852/852), 581.12 KiB | 128.00 KiB/s, done.
处理 delta 中: 100% (16/16), done.
Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to ~/.zshrc
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
Please look over the ~/.zshrc file to select plugins, themes, and options.
p.s. Follow us at https://twitter.com/ohmyzsh.
p.p.s. Get stickers and t-shirts at https://shop.planetargon.com.
重新启动 terminal 就可以看到非常清爽的 oh-my-Zsh 界面