Mac OS终端利器iTerm2(完美替代bash)

iTerm2

iTerm一个为Mac OS X编写的,功能齐全的终端仿真程序;目标是在为用户提供OS X下最佳的命令行体验,iTerm 2有很多能够提升效率的实用功能。比如说窗口分割、热键窗口、智能搜索、自动完成、快速复制等等,其他功能可查看官网的Features页

Term2的安装与配置

  • 第一种直接从官网下载安装包
  • 第二种使用 Homebrew 命令brew cask install iTerm2安装(推荐)
  • 安装后在启动台启动iTerm,快捷键command+,调起配置框

配置环境变量

  • open ~/.zshrc
  • 添加 source ~/.bash_profile

Oh My Zsh安装

Oh My Zsh是对主题的进一步扩展,地址:https://github.com/robbyrussell/oh-my-zsh

  • 一键安装:
    $ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  • 把Zsh设置为当前用户的默认Shell:
    $ chsh -s /bin/zsh
  • 配置agnoster主题,vim ~/.zshrc,插入以下字段,source ~/.zshrc生效
    ZSH_THEME="agnoster"

更改用户名

如果是item2 + oh-my-zsh + agnoster主题组合,cd到 ~/.oh-my-zsh/themes/然后 vim agnoster.zsh-theme,找到如下代码

# Context: user@hostname (who am I and where am I)
prompt_context() {
  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
   # 修改如下代码,标灰色的地方可以自定义
   # prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
   prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@Mac"
  fi
}

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 搜索命令历史
posted @ 2018-12-10 12:35  心若向善  阅读(5011)  评论(0编辑  收藏  举报