mac终端神器:iterm2配色---oh-my-zsh+Powerlevel10k

先看最终效果

首先在官网下载item2

iTerm2 - macOS Terminal Replacement

因为国内基本无法使用github,所以我们选择gitee克隆下载oh-my-zsh

终端命令


git clone https://gitee.com/dongzhe3917875/oh-my-zsh.git

cd oh-my-zsh/tools
sh install.sh

下载完成之后查看我们的默认shell

echo $SHELL

我这里是修改为了zsh

/bin/zsh

如果你的默认shell是bash的话,需要执行命令:将默认shell改为zsh

chsh -s /bin/zsh

接下来我们需要下载所用字体,由于也需要用github,我并没有找到相关链接,故将其上传。

source-code字体-MacOS文档类资源-CSDN下载

网络允许的小伙伴可以在官网下载:https://github.com/adobe-fonts/source-code-pro

下载完后解压并全部添加到字体库,然后再iterm2中设置 

 最后便是下载我们需要的主题Powerlevel10k

我们依然选择gitee镜像安装

git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

安装完成后打开配置文件.zshrc,找到ZSH_THEME="robbyrussell",我们将zsh的主题切换为Powerlevel10k

open ~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"

 接下来重启终端,按照步骤喜好一一设置即可,如果过程中配置错误,可选择终端输入

p10k configure

重新配置

ls配色设置:直接在.zshrc配置文件中添加如下代码即可:

#enables colorin the terminal bash shell export
export CLICOLOR=1

#setsup thecolor scheme for list export
export LSCOLORS=gxfxcxdxbxegedabagacad
 
#sets up theprompt color (currently a green similar to linux terminal)
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$     '
#enables colorfor iTerm
export TERM=xterm-256color

最后我们可以对终端稍加修饰,加上语法高亮,这样错误命令会显示为红色,显而易见。

依然选择gitee下载

git clone https://gitee.com/imirror/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

并且在.zshrc配置文件修改为:plugins=(
  git zsh-autosuggestions zsh-syntax-highlighting
)

修改后保存,终端输入:source ~/.zshrc使其生效