美文网首页
【玩转MAC】——使用iTerm2打造漂亮的终端

【玩转MAC】——使用iTerm2打造漂亮的终端

作者: likly | 来源:发表于2017-10-17 10:36 被阅读0次

一、为什么要使用iTerm2?

一图胜千言。

效果图镇楼效果图镇楼

接下来慢慢说明如何配置如上图的终端效果

二、前期准备

  • 硬件资源
    • 一台装有macos的电脑,黑白苹果都可以
    • 互联网,为下载软件资源做准备
  • 软件资源
    • iTerm2.app终端app
    • oh-my-zsh插件
    • Solarized配色主题
    • 辅助插件

三、iTerm2的安装与配置

3.1 下载与安装

iTerm2是一款免费功能强大的终端替代解决方案,可以直接前往官网下载最新版本的安装包。

官网:http://www.iterm2.com

3.2 配置

  • 配置iTerm2为默认终端
设置iTerm2为默认终端设置iTerm2为默认终端
  • 关闭终端退出确认提示
终端退出配置终端退出配置
  • 默认使用zsh
chsh -s /bin/zsh

四、oh-my-zsh 的安装与配置

【Github】:https://github.com/robbyrussell/oh-my-zsh

4.1 下载与安装

  • curl 指令
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  • wget 指令
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

4.2 主题配置

安装成功后,修改配置文件.zshrc,修改主题为agnoster

ZSH_THEME="agnoster"

该应该是需要特殊的字体支持,否则会出现乱码。

4.3 安装字体支持

使用如下指令安装字体库

//下载字体
git clone https://github.com/powerline/fonts.git --depth=1
//安装字体
cd fonts
./install.sh
配置字体配置字体

五、solarized配色方案

新版本的iTerm2自带了solarized配置方案,如没有,需要下载安装

官网:http://ethanschoonover.com/solarized

  • git clone

    git clone git://github.com/altercation/solarized.git
    
  • 配置


    导入solarized配色方案导入solarized配色方案

六、自动提示命令

  1. 克隆仓库到本地 ~/.oh-my-zsh/custom/plugins 路径下

    git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
    
  2. 用 vim 打开 .zshrc 文件,找到插件设置命令,默认是 plugins=(git) ,我们把它修改为

    plugins=(zsh-autosuggestions git)
    
  3. 重新打开终端窗口。

PS:当你重新打开终端的时候可能看不到变化,可能你的字体颜色太淡了,我们把其改亮一些:
移动到 ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions 路径下

cd ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

vim 打开 zsh-autosuggestions.zsh 文件,修改

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10'

七、语法高亮

  1. 使用homebrew安装 zsh-syntax-highlighting 插件。

    brew install zsh-syntax-highlighting
    
  2. 配置.zshrc文件,插入一行。

    source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
    
  3. 使用配置生效。

    source ~/.zshrc
    

相关文章

网友评论

      本文标题:【玩转MAC】——使用iTerm2打造漂亮的终端

      本文链接:https://www.haomeiwen.com/subject/uzgruxtx.html