本文通过 iTerm2 + oh-my-zsh + Solarized配色方案 来改造我的终端~
iTerm2
- iTerm2 iTerm2是Terminal的替代品,是iTerm的后继产品。它适用于MacOS 10.12或更高版本的Mac。直接在官网上http://iterm2.com/ 下载并安装即可,我这里下载的版本是 3.3.12。
不知道为什么,13M的压缩包我愣是下载来1个多小时。。。。
下载好后直接解压缩,如下图,双击iterm安装
双击iTerm
配置iTerm2
- 将iTerm2设置为默认终端:
(菜单栏)iTerm2 -> Make iTerm2 Default Term
- 设置快捷键
我这里用的是command + .
设置快捷键
安装oh-my-zsh
查看系统里 shell数量
设置系统默认 shell
chsh -s /bin/zsh/ # bash 设置成 zsh
chsh -s /bin/bash/ # zsh 设置成 bash
github地址:https://github.com/robbyrussell/oh-my-zsh
- 使用 crul 安装:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
或
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
- 或使用wget:
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
主题
安装成功后,用vim打开隐藏文件 .zshrc ,修改主题为 agnoster:
vim ~/.zshrc #编辑文件
ZSH_THEME="agnoster" #添加主题
oh-my-zsh 主题:[https://github.com/ohmyzsh/ohmyzsh/wiki/themes] 可以选择自己喜欢的主题,在 .zshrc改下对应的主题名称就行~(https://github.com/ohmyzsh/ohmyzsh/wiki/themes)
应用这个主题需要特殊的字体支持,否则会出现乱码情况,这时我们来配置字体:
1.使用 Meslo 字体,点开连接点击 view raw 下载字体。
2.安装字体到系统字体册。
3.应用字体到iTerm2下,我自己喜欢将字号设置为14px,看着舒服(iTerm -> Preferences -> Profiles -> Text -> Change Font)。
4.重新打开iTerm2窗口,这时便可以看到效果了。
Solarized配色方案
点开官网solarized下载,解压,然后打开 iTerm2 下的偏好设置 preference -->profiles-->colors-->右下角选择import
自动提示命令
当我们输入命令时,终端会自动提示你接下来可能要输入的命令,这时按 → 便可输出这些命令,非常方便。
设置如下:
1.克隆仓库到本地 ~/.oh-my-zsh/custom/plugins 路径下
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
2.用 vim 打开 .zshrc 文件,找到插件设置命令(可以用
/plugins
查找),默认是 plugins=(git) ,把它修改为plugins=(zsh-autosuggestions git)
语法高亮插件
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
vim 配色设置
Vim 的配色最好和终端的配色保持一致,不然在 Terminal/iTerm2 里使用命令行 Vim 会很别扭:
cd solarized
cd vim-colors-solarized/colors #进入solarized 的配色目录
mkdir -p ~/.vim/colors
cp solarized.vim ~/.vim/colors/
vi ~/.vimrc # 设置vim配色
syntax enable
set background=dark
colorscheme solarized
去掉mac 终端上的标题
我把偏好设置中 窗口下的勾选都去掉,只留个shell命令名称和自己命令的标题
但是这个时候 窗口上还是会显示的你电脑的用户名,这个标题看着很不舒服,我想把它改成 L-zsh
的样子,这样看起来会很简洁。 如下图:
这时候需要修改 .zshrc文件的内容,需要找到下面这行,然后把注释给取消
DISABLE_AUTO_TITLE="true"
这样看起来就很简洁了~
多窗口操作
command + d && command + t可进行分屏