Mac Iterm2神器

mac 目前最好用的终端神器没有之一

iterm2

安装iTerm2

下载地址:https://www.iterm2.com/downlo…

也可以通过Homebrew来安装

1
$ brew cask install iterm2

配置

配置ITerm为默认终端

img

配置iTerm2主题

最新版的ITerm2 默认Solarized Dark 可以直接选择

iTerm2 最常用的主题是 Solarized Dark theme

下载地址:http://ethanschoonover.com/so…

下载的是压缩文件,解压后,打开iTerm2,按Command+,键,打开Preferences配置页面,然后Profiles -> Colors -> Color

Presets -> Import,选择刚解压的压缩文件solarized->iterm2-colors-solarized->Solarized Dark.itermcolors文件,导

入成功,最后选择Solarized Dark 主题,就可以了。
img

配置 Oh My Zsh

Oh My Zsh 是对主题的进一步扩展,地址:https://github.com/robbyrusse…

一键安装:

1
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

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

1
$ chsh -s /bin/zsh

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

img
agnoster是比较常用的 zsh 主题之一,你可以挑选你喜欢的主题,zsh 主题列表:https://github.com/robbyrusse…
配置后,效果如下:

img

配置 Meslo 字体

使用上面的主题,需要 Meslo 字体支持,要不然会出现乱码的情况,字体下载地址:Meslo LG M Regular for Powerline.ttf

1
wget https://raw.githubusercontent.com/powerline/fonts/master/Meslo%20Slashed/Meslo%20LG%20M%20Regular%20for%20Powerline.ttf

下载好之后,直接在 Mac OS 中安装即可。

然后打开 iTerm2,按Command + ,键,打开 Preferences 配置界面,然后Profiles -> Text -> Font -> Chanage Font,选择

Meslo LG M Regular for Powerline 字体

img

自动提示填充

这个功能非常的实用,可以提高我们的开发效率

先克隆zsh-autosuggestions项目,到指定目录:

1
$ git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

然后编辑vim ~/.zshrc文件,找到plugins配置,增加zsh-autosuggestions插件。

img

语法高亮

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

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

  1. vim ~/.zshrc配置文件,插入一行,保存退出。

plugins=( … zsh-syntax-highlighting)

  1. 输入命令。

source ~/.zshrc

PS:安装homebrew包管理工具:

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

给ITerm中Vim配色

Vim 的配色最好和终端的配色保持一致,不然在 Terminal/iTerm2 里使用命令行 Vim 会很别扭。

首先下载solarized(上述已经下载过了,进入下载解压后的目录),上文有下载方法和地址。执行以下命令

$ cd solarized

$ cd vim-colors-solarized/colors

$ mkdir -p ~/.vim/colors

$ cp solarized.vim ~/.vim/colors/

$ vi ~/.vimrc

加入下面三行设置即可

syntax enable

set background=dark

colorscheme solarized

给ITerm2中ls配色

1.下载安装 coreutils

brew install coreutils

2.创建颜色配置文件

gdircolors --print-database > ~/.dir_colors

3.启用颜色配置文件

sudo vim ~/.zshrc

添加如下即可----忽略以下

#####if brew list | grep coreutils > /dev/null ; then PATH=“$(brew --prefix coreutils)/libexec/gnubin:$PATH” alias ls=‘ls -F --show-control-chars --color=auto’ eval gdircolors -b $HOME/.dir_colors fi

最后,希望本文对这方面需求的小伙伴,启到帮助的作用!

可用到的参考链接:

fonts

oh–my-zsh

brew 安装及卸载

Mac下Ruby版本管理工具RVM的配置和安装

Mac下终端配置(item2 + oh-my-zsh + solarized配色方案)

开始zsh+vim+iTerm

mac 终端 使用 gnu coreutils 工具 ls 颜色显示

Mac vim iterm2配色方案

iTerm2 快捷命令

命令说明
command + t新建标签
command + w关闭标签
command + 数字 command + 左右方向键切换标签
command + enter切换全屏
command + f查找
command + d垂直分屏
command + shift + d水平分屏
command + option + 方向键 command + [ 或 command + ]切换屏幕
command + ;查看历史命令
command + shift + h查看剪贴板历史
ctrl + u清除当前行
ctrl + l清屏
ctrl + a到行首
ctrl + e到行尾
ctrl + f/b前进后退
ctrl + p上一条命令
ctrl + r搜索命令历史

快捷登陆服务器

img
点击这个或者配置快捷键快速连接

img

最后不想一点击Iterm2就登陆到服务器上,之前默认的不要动还继续默认就行了

带星星的Profile Name就是默认的,修改回最初的配置.

Iterm2关闭警告声音

选中Preferences -> Profiles -> Terminal -> silence bell

img

[oh-my-zsh]异常提示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxrwx 3 polaris admin 96 12 11 10:41 /usr/local/share/zsh
drwxrwxrwx 6 polaris admin 192 12 11 11:19 /usr/local/share/zsh/site-functions

[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.

[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh] compaudit | xargs chmod g-w,o-w

[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.

解决方法

1
2
3
4
5
6
vi .zshrc

==在顶部加入==
ZSH_DISABLE_COMPFIX=true

source .zshrc

公平地讲,zsh-user

对于每个插件都有正确的安装说明,具体取决于操作系统…

Alfred Snippets文字扩展

参考:https://www.jianshu.com/p/afa018018598

扩展包:https://www.alfredapp.com/extras/snippets/