最近重装了系统,因而便从新配置了一下终端,使其更符合用户习惯。git
效果以下:github
拥有语法高亮,命令行tab补全,自动提示符,显示Git仓库状态等功能。vim
安装ruby
首先咱们下载的 iTem2 这个软件,比Mac自带的终端更增强大。直接官网 http://iterm2.com/ 下载并安装便可。bash
配置curl
将iTem2设置为默认终端:ide
(菜单栏)iTerm2 -> Make iTerm2 Default Term工具
而后打开偏好设置preference,选中Keys,勾选Hotkey下的Show/hide iTerm2 with a system-wide hotkey,将热键设置为command+. ,这样你就能够经过command+. 全局热键来打开或关闭iTerm2窗口,很是方便。字体
配色方案url
我选用的是 solarized,效果还不错。点开官网,下载,解压,而后打开 iTerm2 下的偏好设置 preference ,点开 profiles 下的colors 选项,点击右下角的 Color Presets 选项,选择import ,导入解压到的 solarized 文件下的Solarized Dark.itermcolors。
安装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"
|
应用这个主题须要特殊的字体支持,不然会出现乱码状况,这时咱们来配置字体:
1.使用 Meslo 字体,点开链接点击 view raw 下载字体。
2.安装字体到系统字体册。
3.应用字体到iTerm2下,我本身喜欢将字号设置为14px,看着舒服(iTerm -> Preferences -> Profiles -> Text -> Change Font)。
4.从新打开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=(zsh-autosuggestions git)
|
3.从新打开终端窗口。
PS:当你从新打开终端的时候可能看不到变化,可能你的字体颜色太淡了,咱们把其改亮一些:
移动到 ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions 路径下
1
|
cd
~/.oh-my-zsh
/custom/plugins/zsh-autosuggestions
|
用 vim 打开 zsh-autosuggestions.zsh 文件,修改 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10' ( fg=10 在我电脑上显示良好)。
语法高亮
1.使用homebrew安装 zsh-syntax-highlighting 插件。
1
|
brew
install
zsh-syntax-highlighting
|
2.配置.zshrc文件,插入一行。
1
|
source
/usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting
.zsh
|
3.输入命令。
1
|
source
~/.zshrc
|
PS:安装homebrew包管理工具:
1
|
/usr/bin/ruby
-e
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
*这时候打开终端窗口,你的终端看起来就和个人同样漂亮了~
*use it and enjoy it~