iTerm2 自定义效果及美化
文章目录
最终效果展示
1. iTerm2 安装
打开 iTerm2 的 官方网站,选择兼容当前平台的最新版本下载,下载完成后直接安装即可。
2. 设置系统默认终端
运行 iTerm2,依次点击 iTerm2 > Make iTerm2 Default Term
即可设置为系统默认终端。
3. 自定义美化
3.1 切换 ZSH
在 Terminal 终端执行以下命令,会让你输入电脑密码,完成后,需要完全退出 iTerm2。再次进入时,就已经从 bash 切换到 zsh 了。
# 切换 zsh
╭─xuxiaobo@xuxiaobodeMacBook-Pro ~
╰─$ chsh -s /bin/zsh
# 切换 bash
╭─xuxiaobo@xuxiaobodeMacBook-Pro ~
╰─$ chsh -s /bin/bash
# 查看本机安装哪些shell
╭─xuxiaobo@xuxiaobodeMacBook-Pro ~
╰─$ cat /etc/shells
3.2 字体安装
在 Terminal 终端执行以下命令把文件克隆到本地,然后进入工程目录的 Monaco
目录,双击后缀名为 .otf
的字体文件即可完成该字体的安装。安装该字体的原因主要是为了和 Oh-My-Zsh 的 powerlevel9k 主题相兼容,如果不安装该字体,那么后面安装 powerlevel9kn 主题后会出现乱码。安装完后打开 iTerm2,依次选择菜单栏:iTerm2 > Preferences > Profiles > Text > Font & Non-ASCII Font
进行设置 Powerline 的字体,具体可以参考以下截图。
# 该仓库中包含好几种优化后的字体
╭─xuxiaobo@xuxiaobodeMacBook-Pro ~
╰─$ git clone https://github.com/supermarin/powerline-fonts.git
3.3 oh-my-zsh 安装
如果是 Linux,默认没有 ZSH,所以要先安装 ZSH。Mac 默认安装了 ZSH,直接可执行以下命令安装 oh-my-zsh
:
# 安装oh-my-zsh
╭─xuxiaobo@xuxiaobodeMacBook-Pro ~
╰─$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Found ~/.zshrc. Backing up to /Users/jinyaochen/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc.
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.
• Follow us on Twitter: https://twitter.com/ohmyzsh
• Join our Discord server: https://discord.gg/ohmyzsh
• Get stickers, shirts, coffee mugs and other swag: https://shop.planetargon.com/collections/oh-my-zsh
3.4 配置语法高亮
Zsh-syntax-highlighting
插件可以使你终端输入的命令有语法高亮效果,通过以下命令可以快速下载安装。
# 下载安装 zsh-syntax-highlighting 插件
╭─xuxiaobo@xuxiaobodeMacBook-Pro ~
╰─$ brew install zsh-syntax-highlighting
3.5 主题安装
Powerlevel9k 的好处就是可以做很多自定义,只需要简单修改 ~/.zshrc
配置即可生效。更多关于该主题的定制请 点击查看 。
扫描二维码关注公众号,回复:
13141944 查看本文章
# 克隆该仓库到 oh-my-zsh 用户自定义主题目录
╭─xuxiaobo@xuxiaobodeMacBook-Pro ~
╰─$ git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
# 修改 ~/.zshrc 配置文件,配置该主题
╭─xuxiaobo@xuxiaobodeMacBook-Pro ~
╰─$ vi ~/.zshrc
export ZSH="/Users/xuxiaobo/.oh-my-zsh"
# 修改这里的皮肤名字即可切换不同的主题
ZSH_THEME="bira"