安装 iTerm2 终端

下载地址

使用Homwbrew安装

1
brew install iterm2  

配置 iTerm2 终端

设置iTerm2为默认终端

访达菜单 iTerm2 > Make iTerm2 Default Term 选择设置默认即可!

配置主题

主题推荐

draculatheme 主题

Solarized Dark theme 主题

Iterm2-color-schemes 主题

主题配置

打开iTerm2 -> Preferences,然后Profiles —-> Colors -> Color Presets -> Import ,选择刚刚解压的solarized->iterm2-colors-solarized->Solarized Dark.itermcolors文件,导入成功,最后选择Solarized Dark

注意: import 导入主题的时候

Iterm2-color-schemes 选择 `schemes` 文件夹下文件!

安装 oh-my-zsh

oh-my-zsh 是对主题的进一步扩展

安装

使用 curl 安装:

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

主题配置

  1. 主题修改
1
vim ~/.zshrc
1
ZSH_THEME="agnoster"
  1. 声明高亮

执行以下命令

1
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 

编辑.zshrc

1
vim ~/.zshrc

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

1
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
  1. 自动填充建议
1
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

同上,将插件添加到 plugins配置下!

1
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
  1. iTerm2隐藏用户名和主机名

有时候我们的用户名和主机名太长,比如我的xishuai@xishuaideMacBook-Pro,终端显示的时候会很不好看,我们可以手动去除。
编辑 vim ~/.zshrc 文件,增加 DEFAULT_USER="xishuai" 配置,可在文本最好追加我们可以通过whoami 命令,查看当前用户

1
2
ZSH_THEME="agnoster" 
DEFAULT_USER="pactepacterara"

iTerm2 快捷命令

命令描述
command + enter进入与返回全屏模式
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搜索命令历史