mac终端神器iterm2安装

2020-02-28  本文已影响0人  爱吃油果子

让你的命令行告别黑白,进入彩色时代!


Solarized Dark 主题效果
Tango Dark 主题效果

1. iterm2 安装

下载安装:https://www.iterm2.com/downloads.html
或使用 Homebrew命令安装:

brew cask install iterm2

2. 配置 iTerm2 主题

iTerm2 最常用的主题是 Solarized Dark theme,下载地址
http://ethanschoonover.com/solarized
下载的是压缩文件,你先解压一下,然后打开 iTerm2,按Command + ,键,打开 Preferences 配置界面,然后Profiles -> Colors -> Color Presets -> Import,选择刚才解压的solarized -> iterm2-colors-solarized -> Solarized Dark.itermcolors文件,导入成功,最后选择 Solarized Dark 主题。

配置 iTerm2 主题

3. 配置 Oh My Zsh

Oh My Zsh 是对主题的进一步扩展,地址:https://github.com/robbyrussell/oh-my-zsh
一键安装命令:

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

安装好之后,需要把 Zsh 设置为当前用户的默认 Shell(这样新建标签的时候才会使用 Zsh)运行命令:

chsh -s /bin/zsh

执行成功后,查看当前shell

$ echo $SHELL 
/bin/zsh

我们编辑vi ~/.zshrc文件,将主题配置修改为ZSH_THEME="agnoster"


agnoster主题配置

4. 配置 Meslo 字体

使用上面的主题,需要 Meslo 字体支持,否则会出现乱码,字体下载地址:Meslo LG M Regular for Powerline.ttf(执行下面命令下载并安装)

git clone git@github.com:powerline/fonts.git
# 安装
./fonts/install.sh

然后打开 iTerm2,按Command + ,键,打开 Preferences 配置界面,然后Profiles -> Text -> Font -> Chanage Font,选择 Meslo LG M Regular for Powerline 字体。


字体设置

5. 安装高亮插件

cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

编辑vi ~/.zshrc文件


增加高亮插件
plugins=(
        git
        zsh-syntax-highlighting
        )
配置高亮
# 刷新mac本来的配置
source ~/.bash_profile
# 刷新别名
source ~/.bashrc
# 必须保证高亮插件在最后
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

最后,刷新配置看看效果:source ~/.zshrc


Solarized Dark 主题效果

6. 快捷键配置

本文参考:https://www.jianshu.com/p/459d7a8f4613

上一篇 下一篇

猜你喜欢

热点阅读