为了账号安全,请及时绑定邮箱和手机立即绑定

MacOS iterm2 配置 「zsh」 + 「oh my zsh」 +「powerlevel10k」定制您的终端环境

Mac OS自带的终端,用起来有些不太方便,界面也不够友好, iTerm2是一款相对比较好用的终端工具,也可以说是 Terminal 的替代品,它适用于 macOS 10.12 或更高版本的 macOS。iTerm2常用操作包括主题选择、声明高亮、自动填充建议、隐藏用户名和主机名、分屏效果等,这些功能极大的提高我们敲命令的效率,强烈推荐每一个程序员都尝试和习惯使用这款工具。

效果图如下:

截屏2022-07-05 21.24.45

安装 iTerm2

  • brew 方式安装: brew install iterm2
  • 通过 MacWk 下载安装,博主采用这种方式,这里面有很多破解软件哦,下载地址
  • 通过官网下载安装,下载地址

安装以及配置 Oh My Zsh

  • 官网方式,该方式可能因为网络原因安装不成功,那请换其他方式安装【不推荐】

sh -c "$(curl -fsSL https://githubcdn.qiushaocloud.top/gh/qiushaocloud/ohmyzsh@master/tools/install.sh)"

  • git 仓库方式

    # 下载 oh-my-zsh 源码
    git clone https://gitee.com/qiushaocloud/ohmyzsh.git ~/.oh-my-zsh
    # git clone https://github.com/qiushaocloud/ohmyzsh.git ~/.oh-my-zsh
    # 并且把 .zshrc 配置文件拷贝到根目录下
    cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
    # 让 .zshrc 配置文件生效
    source ~/.zshrc
    ## shell换成zsh
    chsh -s /bin/zsh
    
    
  • oh-my-zsh GitHub 上下载 zip -> 解压 -> 移动 oh-my-zsh 目录到根目录

    cd ~/Downloads
    mv ohmyzsh-master ~/.oh-my-zsh
    cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
    source ~/.zshrc
    
    

下载以及配置 solarized 配色主题【有些 item2 已经有这个主题,直接用就好了】

cd ~/Downloads
# 下载 solarized 主题源码
git clone https://gitee.com/qiushaocloud/solarized.git
# git clone https://github.com/qiushaocloud/solarized.git

然后打开 iTerm2, 按 Command + , 键, 打开 Preferences 配置界面, 然后 Profiles -> Colors -> Color Presets -> Import , 在弹出的窗口中, 定位到 Downloads > solarized > iterm2-colors-solarized , 双击 Solarized Dark.itermcolors 导入暗色的 Solarized 配色方案. 就可以了.

img

如果你有强迫症, 下载的文件可以删除

安装以及配置神器 Powerlevel10k

Powerlevel10k 简单来说就是一个 ZSH 的主题,只不过它的功能很强大,以下简称 p10k

git clone  https://gitee.com/qiushaocloud/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k
# git clone  https://github.com/qiushaocloud/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k

然后需要打开 ~/.zshrc 设置 ZSH_THEME:

ZSH_THEME="powerlevel10k/powerlevel10k"

安装以及设置字体 Nerd Fonts

打开 https://github.com/ryanoasis/nerd-fonts/releases,滑动页面找到 Assets 区域,如图:

img

我们只要下载箭头所指的 Hack.zip 这个字体包,解压缩之后就会获得一些 ttf 字体文件,双击安装即可。如果您没办法打开下载,您也可以使用此地址下载:https://githubcdn.qiushaocloud.top/gh/qiushaocloud-cdn/cdn_static@master/Hack.zip

zshrc 设置字体
POWERLEVEL9K_MODE="nerdfont-complete"
ZSH_THEME="powerlevel10k/powerlevel10k"

注意,需要设置在 ZSH_THEME 之前。

iTerm2 设置字体

操作路径:菜单栏 -> Profiles -> Open Profiles -> Edit Profiles -> 选择 Text

img

这样,所有的图标就都可以正常显示了。

VS Code 字体配置

如果你用的是 VS Code,需要再配置一下字体,settings.json 内容设置如下:

{
  "terminal.integrated.fontFamily": "Hack Nerd Font"
}

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消