Mac下终端配置item2 + oh-my-zsh + solarized配色方案
最近重新安装了一下MacOS Mojave系统于是开始了工具折腾,众所周知Mac下的Terminal非常不好用,item2堪称Mac下的神器,重新配置了一下item2,使其更符合用户习惯。效果如下:
拥有语法高亮,命令行tab补全,自动提示符,显示Git仓库状态等功能
安装item2
1、去item2官网 http://www.iterm2.com/ 下载最新版本的,下载完成即可使用
2、将iTem2设置为默认终端:
(菜单栏)iTerm2 -> Make iTerm2 Default Term
3、打开偏好设置preference,选中Keys,勾选Hotkey下的Show/hide iTerm2 with a system-wide hotkey,将热键设置为command+. ,这样你就可以通过command+.全局热键来打开或关闭iTerm2窗口,非常方便。
配色
我选用的是 solarized,效果还不错。点开官网,下载,解压,然后打开 iTerm2 下的偏好设置 preference ,点开 profiles 下的colors 选项,点击右下角的 Color Presets 选项,选择import ,导入解压到的 solarized 文件下的Solarized Dark.itermcolors。
oh-my-zsh 安装(github链接)
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 -)" |
1、主题设置
vim打开隐藏文件 .zshrc
1 | vim ~/.zshrc |
修改主题为ys
1 | ZSH_THEME="ys" |
2、使用 Meslo 字体,点开连接点击 view raw 下载字体。
3、双击安装字体到系统字体册
4、应用字体到iTerm2下,我自己喜欢将字号设置为14px,看着舒服(iTerm -> Preferences -> Profiles -> Text -> Change Font)。
5、重新打开iTerm2窗口,就可以看到效果了
自动提示命令
当我们输入命令时,终端会自动提示你接下来可能要输入的命令,这时按 → 便可输出这些命令,非常方便。
1、克隆仓库到本地 ~/.oh-my-zsh/custom/plugins 路径下
1 | git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions |
2、用 vim 打开 .zshrc 文件,找到插件设置命令,默认是 plugins=(git) ,我们把它修改为
1 | plugins=( |
3、重新打开终端窗口
当你重新打开终端的时候可能看不到变化,可能你的字体颜色太淡了,我们把其改亮一些:
cd ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
用 vim 打开 zsh-autosuggestions.zsh 文件,修改 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE=’fg=10’
语法高亮
1、设置vim syntax on
用vim打开.vimrc
1 | vim ~/.vimrc |
添加代码
1 | syntax on |
2、使用homebrew安装 zsh-syntax-highlighting 插件
1 | brew install zsh-syntax-highlighting |
3、配置.zshrc文件,插入一行
1 | source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh |
source 这行一定在最后面
4、输入命令
1 | source ~/.zshrc |
ps安装homebrew包管理工具 参考官网 https://brew.sh/
赶快试试吧,看到优雅的终端,写代码也会飞吧!
赏
使用支付宝打赏
使用微信打赏
若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏
扫描二维码,分享此文章