https://swp-song.com/2017/08/20/Tools/OhMyZsh%E5%AE%89%E8%A3%85%E5%92%8C%E4%B8%BB%E9%A2%98%E9%85%8D%E7%BD%AE%E6%96%B9%E6%B3%95/
Oh MyZsh 是什么
Zsh 是什么
-
Zsh,它是一种命令行程序。我们 Mac 系统上默认使用的 bash 命令行,而 Zsh 是另外一种命令行环境。
- 我们可以在命令行中输入 zsh –version 这个命令来查看我们的电脑上是否安装了 Zsh
- 终端查询版本为: zsh 5.2 (x86_64-apple-darwin16.0)
- 查看系统当前 shell,cat /etc/shells
-
zsh 虽然功能强大,但刚上手配置比较麻烦。所以我们用 Oh My Zsh 替换掉 Zsh。
安装 Oh My Zsh 方法
- 可以通过 curl 或 wget 两种方式来安装,用一条命令即可安装。
1
|
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
|
1
|
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
xxxx% sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" Cloning Oh My Zsh... Cloning into '/Users/xxxx/.oh-my-zsh'... remote: Counting objects: 831, done. remote: Compressing objects: 100% (700/700), done. remote: Total 831 (delta 14), reused 775 (delta 10), pack-reused 0 Receiving objects: 100% (831/831), 567.67 KiB | 75.00 KiB/s, done. Resolving deltas: 100% (14/14), done. Looking for an existing zsh config... Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh 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 http://shop.planetargon.com.
|
设置主题
- 安装完毕后,我们就可以使用了,先来简单配置一下,Oh My Zsh 提供了很多主题风格,我们可以根据自己的喜好,设置主题风格
- 终端输入命令 open ~/.zshrc。
- 找到 ZSH_THEME ,ZSH_THEME=”robbyrussell” ,robbyrussell ,是默认的主题,修改 ZSH_THEME=” 样式名称”
- 保存这个文件文件,重新打开终端。
- 步骤同上
- ZSH_THEME=”random”
- 每次打开终端主题是随机的。
- 终端输出:[oh-my-zsh] Random theme ‘/Users/xxxx/.oh-my-zsh/themes/zhann.zsh-theme’ loaded…,其中 zhann.zsh-theme 是主题的名称, 有喜欢的童鞋可以记录保留
查看主题名称
-
Oh My Zsh 默认自带了一些默认主题,存放在 ~/.oh-my-zsh/themes 目录中。我们可以查看这些主题
- 终端输入:
- ~/.oh-my-zsh/themes
- 查看:
- ls
- 查看结果:
卸载 Oh My Zsh
- 终端输入 :
- uninstall_oh_my_zsh
- Are you sure you want to remove Oh My Zsh? [y/N] Y
- 终端提示信息:
1 2 3 4 5 6
|
Removing ~/.oh-my-zsh Looking for original zsh config... Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc Found ~/.zshrc -- Renaming to ~/.zshrc.omz-uninstalled-20170820200007 Your original zsh config was restored. Please restart your session. Thanks for trying out Oh My Zsh. It's been uninstalled.
|
Tips:
-
Oh My Zsh 的自动更新提示误触关掉了解决办法
- 打开终端输入:
- upgrade_oh_my_zsh
- 如果不喜欢系统自带终端,笔者推荐一个强大的终端 App。
-
iTerm2,非常好用的一个终端软件。
- iTerm2 下载地址