iTerm2的安装
1. 直接官网下载
下载地址: https://www.iterm2.com/downloads.html
下载的是压缩文件,解压后直接双击执行程序文件,或者直接将它拖到 Applications 目录下即可。
2. 使用Homebrew安装
brew cask install iterm2
Homebrew的安装(已安装Homebrew的请忽略此操作)
# install brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
# uninstall brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
# cat version
brew -v
# update
brew update
# 自检
/usr/local/bin/brew doctor
iTerm2的配置
1. 配置Oh My Zsh
Oh My Zsh 是对主题的进一步扩展,下载地址https://github.com/robbyrussell/oh-my-zsh
- 一键安装:
wget方式
$sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
wget的安装(已安装Wget的请忽略此操作)
# install
brew install wget
# 查看版本
wget —version
- 手动安装 :
git地址https://github.com/ohmyzsh/ohmyzsh
# clone到本地
git clone https://github.com/ohmyzsh/ohmyzsh.git
# 复制文件夹
cp -r ohmyzsh ~/.oh-my-zsh
# 复制配置文件
cp ohmyzsh/templates/zshrc.zsh-template ~/.zshrc
# 切换shell
chsh -s /bin/zsh
打开终端发现权限问题,解决如下:
chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions
# 修改配置文件
vim ~/.zshrc
输入i进入编辑模式,将ZSH_THEME=""编辑为 ZSH_THEME="agnoster"
按下esc键,退出编辑,:wq保存退出。
2. 配置iTerm2的主题
iTerm2 最常用的主题是 Solarized Dark theme,下载地址:
http://ethanschoonover.com/solarized
https://github.com/altercation/solarized github地址
# clone到本地
git clone https://github.com/altercation/solarized.git
打开 iTerm2,按Command +,键,打开 Preferences配置界面,然后 Profiles -> Colors -> Color Presets,在下拉列表中选择 Import,选择clone到本地的solarized->iterm2-colors-solarized->Solarized Dark.itermcolors文件。导入成功后,在 Color Presets下选择 Solarized Dark主题,就可以了。
3. 设置 iTerm2 的背景图片
打开 iTerm2,按Command +,键,打开Preferences 配置界面Profiles -> Window->Background mage,选择一张自己喜欢的背景图。
4. 配置Meslo字体
使用 Solarized Dark主题,需要 Meslo字体支持,要不然会出现乱码的情况。
- 安装
PowerLine(状态栏工具 )
# 先安装pip命令:pip是python的一个维护命令
sudo easy_install pip
# 安装Powerline:(—user好像是表示基于用户的权限)
pip install powerline-status --user
- 安装
PowerFonts字体
#—depth=1表示值clone最近一次commit的
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
# 运行install shell
./install.sh
然后打开iTerm2,按Command + ,键,打开Preferences配置界面,然后Profiles -> Text -> Font ->Chanage Font,选择 Meslo LG S Regular for Powerline 字体。
5. 配置高亮
配置后,特殊命令和错误命令,会有高亮显示。
- 使用brew安装
# install
brew install zsh-syntax-highlighting
# uninstall
brew uninstall zsh-syntax-highlighting
- clone到本地安装
cd ~/.oh-my-zsh/custom/plugins/
# clone到本地
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# 编辑配置文件
vim ~/.zshrc
输入i进入编辑模式,将plugins=""编辑为 plugins=(git zsh-syntax-highlighting),如图
注意:要保证zsh-syntax-highlighting在plugins字段的最后一个
再在配置文件最后一行增加下面配置:
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
然后按下esc键退出编辑,输入:wq保存退出。如图
6. 配置自动建议填充
这个功能是非常实用的,可以方便我们快速的敲命令。
# clone到指定目录
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
# 编辑配置文件
vim ~/.zshrc
输入i进入编辑模式,将plugins=""编辑为 plugins=(git zsh-autosuggestions zsh-syntax-highlighting),然后按下esc键退出编辑,输入:wq保存退出。如图
注意:要保证zsh-syntax-highlighting在plugins字段的最后一个
7. 配置快速隐藏和显示iTerm2 窗口
打开 iTerm2,按Command + ,键,打开Preferences配置界面,然后Profiles→ Keys →Hotkey,自定义一个快捷键即可。如图:
8. iTerm2的快捷指令
在iterm2中,选中某个路径或者某个词汇,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 搜索命令历史










网友评论