安装环境

  • Mac M1 Pro
  • Ventura 13.3

安装Homebrew

安装MacOS下包管理工具homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

安装之后的软件都在 /opt/homebrew/Cellar/下,配置文件都在/opt/homebrew/etc/

brew --version
Homebrew 4.0.11

目前最新的版本是4.0.11

下载iTerm2

brew install --cask iTerm2

iTerm2主题文件

下载主题文件

iTerm2主题文件schemes目录中,这里我使用的是Solarized Dark Higher Contrast.itermcolors主题

导入主题文件

打开Settings页面,选择刚才下载的主题文件

路径:Profiles –> Colors –> Color Presets –> Import –> 选择你刚才下载的主题

themes

oh-my-zsh

安装

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

修改当前的shell为zsh

#查看当前使用的Shell
echo $SHELL
#修改默认Shell为zsh,这一步需要输入用户密码
chsh -s /bin/zsh
#查看当前使用的Shell
echo $SHELL

如果结果是/bin/zsh,就不需要修改。

更换oh-my-zsh主题

主题预览

进入编辑~/.zshrc,凡是修改了改文件,记得都要source ~/.zshrc刷新配置文件

vi ~/.zshrc

编辑ZSH_THEME的值为你喜欢的主题,例如我这里用的是agnoster

modified theme

安装powerline font

当更改主题后,可能会显示乱码,这是因为没有安装主题所需要的字体文件

这里我安装的是Meslo LG M Regular for Powerline.ttf

下载完成后,直接双击安装即可。

安装git字体

#先使用git命令克隆
git clone https://ghproxy.com/https://github.com/powerline/fonts.git --depth=1

# 进入克隆到本地的fonts目录进行安装
cd fonts
./install.sh

# 删除克隆到本地的目录
cd ..
rm -rf fonts

修改字体

打开iTerm2,打开Preferences配置界面,选择 Meslo LG M Regular for Powerline 字体。
路径:Profiles -> Text -> Font

change-font

安装插件

这里我安装了三个常用的插件zsh-syntax-highlightingzsh-autosuggestionsautojump

# 安装高亮插件
brew install zsh-syntax-highlighting
# 安装自动填充建议插件
brew install zsh-autosuggestions
# 安装快速跳转插件
brew install autojump

# 编辑~/.zshrc
vi ~/.zshrc
# 刷新~/.zshrc
source ~/.zshrc

~/.zshrc追加内容,如下

# on-my-zsh plugins
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# zsh-autosuggestions
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# autjump
[ -f /opt/homebrew/etc/profile.d/autojump.sh ] && . /opt/homebrew/etc/profile.d/autojump.sh

每个插件安装完成后,控制台会输出日志,提示你怎么激活

例如 zsh-syntax-highlighting:

To activate the syntax highlighting, add the following at the end of your .zshrc:
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

If you receive "highlighters directory not found" error message,
you may need to add the following to your .zshenv:
export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/opt/homebrew/share/zsh-syntax-highlighting/highlighters

这个就告诉了你,需要把source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh这一行追加到.zshrc的末尾。

常用设置

隐藏用户名

#编辑配置文件
vim ~/.zshrc
#在文件最后增加 DEFAULT_USER=$USER
DEFAULT_USER=$USER
#退出编辑后执行使配置生效
source ~/.zshrc

default user

设置Status Bar

Profiles -> session-> 勾选 Status bar enable-> configure Status bar

status bar

根据需要,拖拽自己想要的状态栏显示

截屏2023-04-06 14.29.06

水印

Profiles -> General

水印