文章目录
iTerm2
安装iTerm2
- 从iTerm2官方下载地址下载iTerm2
- 解压缩下载下来的zip文件,得到iTerm2,双击打开并将其添加进Application文件中
iTerm2偏好设置
- 可以通过偏好设置把iTerm2设置为默认终端
- 设置快捷键
- 然后打开偏好设置preference
- 选中Keys
- 勾选Hotkey下的Show/hide iTerm2 with a system-wide hotkey
- 将热键设置为command+T
- 通过command+T 全局热键来打开或关闭iTerm2窗口
配置iTerm2
- 当把shell 语言从bash换成zsh之后,此时每次打开iTerm2执行的文件是~/.zshrc
- .bash_profile 或 .bashrc之前的设置必须在每次打开iTerm2时候source ~/.bash_profile才能生效
- 使用vim打开~/.zshrc,在文件里加入一行
source ~/.bash_profile
配色方案
- 解压
- 打开 iTerm2 下的偏好设置 preference
- 点开 profiles 下的colors 选项
- 点击右下角的 Color Presets 选项
- 选择import
- 导入解压到的 solarized 文件下的Solarized Dark.itermcolors
- 此时原来的配色方案多出了Solarized Dark一项,点击选择,重新打开iTerm即可
安装Oh My Zsh
- 在终端使用命令行cat /etc/shells,查看当前系统可以使用的shell
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
- 使用命令行echo $SHELL命令查看当前正在使用的shell
# Mac系统中默认的shell为bash shell
/bin/bash
- 如果当前的shell不是zsh,可以通过chsh -s /bin/zsh命令将shell切换为shell之zsh,终端重启之后即可生效
- 将shell切换为zsh之后,可以继续安装Oh My ZSH
- 官方推荐的安装方法为
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- 此过程应关闭代理(不能翻墙)
- 出现以下图形表示安装成功
配置agnoster主题
-
Oh My Zsh提供了所有主题在线预览
-
安装成功之后,通过命令行vi ~/.zshrc,设置ZSH_THEME="agnoster"对主题进行修改。
配置字体
- 应用这个主题需要特殊的字体支持,否则会出现乱码情况。使用 Meslo 字体,点开连接点击 view raw 下载字体。
- 双击ttf文件,安装字体到系统字体册
- 应用字体到iTerm2下,将字号设置为14px(iTerm -> Preferences -> Profiles -> Text -> Change Font)
- 重新打开iTerm2窗口,这时便可以看到效果了
透明度
Term2->preferences->Profiles,右侧找到window选项卡,拖动Transparency调整
自动提示命令
- 克隆仓库到本地 ~/.oh-my-zsh/custom/plugins 路径下
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
- 用 vim 打开 .zshrc 文件,找到插件设置命令,默认是 plugins=(git) ,把它修改为
plugins=(zsh-autosuggestions git)
设置语法高亮
- 使用homebrew安装 zsh-syntax-highlighting 插件:
brew install zsh-syntax-highlighting
- 配置.zshrc文件
vim ~/.zshrc
- 在最后插入下面这一行代码:
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
- 输入命令重新加载配置文件:
source ~/.zshrc
隐藏用户名信息
- 进入oh-my-zsh的agnoster主题,编辑agnoster.zsh-theme文件
vim ~/.oh-my-zsh/themes/agnoster.zsh-theme
- 注释掉红框内的语句
参考博客
http://www.siguoya.name/pc/home/article/256
https://www.cnblogs.com/weixuqin/p/7029177.html