安装
首先我们下载的 iTem2 这个软件,比Mac自带的终端更加强大。直接官网 http://iterm2.com/ 下载并安装即可。
安装oh-my-zsh
github连接:https://github.com/robbyrussell/oh-my-zsh
使用 crul 安装:1
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
或使用wget:1
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
主题
安装成功后,用vim打开隐藏文件 .zshrc ,修改主题为 agnoster:1
ZSH_THEME="agnoster"
应用这个主题需要特殊的字体支持,否则会出现乱码情况,这时我们来配置字体:
- 使用 Meslo 字体,点开连接点击 view raw 下载字体。
- 安装字体到系统字体册。
- 应用字体到iTerm2下,我自己喜欢将字号设置为14px,看着舒服(iTerm -> Preferences -> Profiles -> Text -> Change Font)。
- 重新打开iTerm2窗口,这时便可以看到效果了。
自动提示命令
当我们输入命令时,终端会自动提示你接下来可能要输入的命令,这时按 → 便可输出这些命令,非常方便。
设置如下:
克隆仓库到本地 ~/.oh-my-zsh/custom/plugins 路径下
1
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
用 vim 打开 .zshrc 文件,找到插件设置命令,默认是 plugins=(git) ,我们把它修改为
1
plugins=(zsh-autosuggestions git)
语法高亮
- 使用homebrew安装 zsh-syntax-highlighting 插件。
- 配置.zshrc文件,插入一行。
- 输入命令。
1 | brew install zsh-syntax-highlighting |