iterm在mac中使用

150 阅读2分钟

安装使用

  • 去官网下载iterm
    • 或者是如果之前安装了homebrew 可以通过 brew cask install iterm2
  • 安装homebrew
    • /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" speed 
    • 后续安装 都可以使用 brew install xxx
  • 安装oh-my-zsh
    • sh -c "$(curl -fsSL ``https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    • 安装好之后,需要把 Zsh 设置为当前用户的默认 Shell(这样新建标签的时候才会使用 Zsh):
      • chsh -s /bin/zsh
    • 更换主题
    • zsh默认带了很多主题
      • cd ~/.oh-my-zsh/themes
      • 里面有很多文件 都是主题,将文件名称 改到上一步就完成了更改主题
      • 更改完成之后 重启 或者 source ~/.zshrc
    • 自动建议填充
      • git clone https://github.com/zsh-users/zsh-autosuggestions~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
      • 然后编辑vim ~/.zshrc文件,找到plugins配置,增加zsh-autosuggestions插件
      • source ~/.zshrc
github访问太慢,并且仓库地址不正确一直报443,所以换以下路径,clone
git clone https://gitee.com/phpxxo/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
    • 声明高亮
      • cd ~/.oh-my-zsh/custom/plugins
      • git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
      • vim ~/.zshrc -- 如果没有权限 增加 sudo
      • 修改 plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
      • source ~/.zshrc -- 让改动生效

快捷命令

标签
新建标签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 + a
到行尾ctrl + e
前进后退ctrl + f/b (相当于左右方向键)
上一条命令ctrl + p
搜索命令历史ctrl + r
删除当前光标的字符ctrl + d
删除光标之前的字符ctrl + h
删除光标之前的单词ctrl + w
删除到文本末尾ctrl + k
交换光标处文本ctrl + t
清屏1command + r
清屏2ctrl + l

有可能遇到的问题 & 解决方案

  • 默认输入类似 git branch / 的时候会进入vim编辑页面
    • git config --global core.pager ''
  • 配置不生效
    • 修改zshrc 文件之后
      • source ~/.zshrc
    • 重启生效