Mac系统终端iTerm2

  1. 安装iTerm2
  2. 安装Oh My Zsh
    1. 修改 zsh主题
  3. 配置iTerm2的主题
  4. 设置 iTerm2 的背景图片
  5. 设置 iTerm2 的背景图片
  6. 配置高亮
  7. 配置自动建议填充
  8. 配置插件
  9. iTerm2的快捷指令

iTerm2 是一个 MacOS 终端工具,https://iterm2.com/index.html

安装iTerm2

  1. 直接下载安装
    官方下载地址:https://iterm2.com/downloads.html
    下载的是压缩文件,解压后直接双击执行程序文件,或者直接将它拖到 Applications 目录下即可。

  2. 使用Homebrew安装

    brew cask install iterm2
    

    安装Oh My Zsh

    # 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
    

    修改 zsh主题

    编辑 ~/.zshrc,将 ZSH_THEME="" 编辑为 ZSH_THEME="agnoster"

配置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 的背景图片

打开 iTerm2,按Command +,键,打开 Preferences配置界面,然后 Profiles -> Colors -> Color Presets,在下拉列表中选择 Import,选择clone到本地的solarized->iterm2-colors-solarized->Solarized Dark.itermcolors文件。导入成功后,在 Color Presets下选择 Solarized Dark主题,就可以了。

设置 iTerm2 的背景图片

打开 iTerm2,按Command +,键,打开Preferences 配置界面Profiles -> Window->Background mage,选择一张自己喜欢的背景图。

配置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 字体。

配置高亮

# install 高亮
brew install zsh-syntax-highlighting

# 插件目录
cd ~/.oh-my-zsh/custom/plugins/

# clone到本地
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting

再在配置文件最后一行增加下面配置:

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

配置自动建议填充

这个功能是非常实用的,可以方便我们快速的敲命令。

# clone到指定目录
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

配置插件

# 修改 ~/.zshrc
vim ~/.zshrc
# 配置 plugins 
plugins=(git  zsh-autosuggestions zsh-syntax-highlighting)

注意:要保证zsh-syntax-highlighting在plugins字段的最后一个

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    搜索命令历史

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 lzdong@foxmail.com

×

喜欢就点赞,疼爱就打赏