macOS——配置自己终端的过程(ZSH)

发布时间 2023-03-29 01:47:25作者: Transirizo

首先查看oh-my-zsh的官网:https://ohmyz.sh/

在终端使用curl命令进行安装 ,可以点击DOC标签进入他们的github进行查看。

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

我并没有使用官方的主题,用的是powerlevel10K,其GitHub是:https://github.com/romkatv/powerlevel10k#oh-my-zsh

GitHub上有关于ohmyzsh的安装方法。

 

 

 其命令为:

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

按照步骤,第二步是在.zshrc文件内更改主题项。

即 vim ~/.zshrc  更改相关项,:wq保存退出,然后可以重开终端或者运行 source ~/.zshrc命令。

然后根据提示进行选择项目配置该主题,但有个问题是如果没有使用官方推荐字体或者支持emoji在终端显示的字体的话,对于有图标的主题将无法使用,所以进行安装官方推荐字体,即 MesloLGS字体。

安装完毕后,根据文档进行修改终端字体。

 

 

 然后我根据配置选择就得到这样的终端样式:

 

 

 接下来安装autojump插件,GitHub:https://github.com/wting/autojump

按照文档的安装,我采用Homebrew安装方法:

brew install autojump

安装后会在brew的文件夹里,所以要在zsh文件中引入它。

首先是plugins()里面添加,再在文件最下方添加路径。

然而我在brew install 中出现了 Error:Command failed with exit 128: git

运行brew doctor,根据相关提示进行修正。

  [ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh

添加至.zshrc文件最底部。

安装zsh-autosuggestion插件,GitHub:https://github.com/zsh-users/zsh-autosuggestions

运行命令:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

并在plugins加入该插件名。

同上,安装zsh-syntax-highlighting插件,GitHub:https://github.com/zsh-users/zsh-syntax-highlighting

命令:

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

并在plugins加入该插件名。

./zshrc文件中的plugins应该是这样的:

 

 进行source ~/.zshrc 或者重开终端,就已经完全配置好这三个插件和主题了。