Mac iTerm2的终端美化
iTerm2
关于iTerm2的一些特性不必再赘述,网上有很多教程,这里我记录一些我自己要用或者要配置的,方便后续自己看看笔记。
Date:2023.08.02
Author: libaige
1.安装oh-my-zsh
oh-my-zsh也是命令行工具,总而言之就是比系统自带bash颜值更高、能力更强。同时支持很多自定义选项和扩展。
这里直接将通过命令安装:
# curl命令
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# wget命令
sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# fetch命令
sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)
这里可以直接通过终端安装,当然如果网速
不太好就会咩有办法下载,于是乎你可以尝试通过这样的方式来走一次代理,比如国内有可以用的镜像代理之类的自己找如下所示:
此时,终端就应该变成现在这个样子👇:
2.安装终端字体
接下来还可以安装字体库,设置一个自己喜欢的字体,方法如下:
# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts
安装好之后,选择一款Powerline字体了:
iterm2 -> Preferences -> Profiles -> Text -> Font -> Change Font
3.安装iTerm的主题
点这里👇
安装主题参考的Wiki
这里主题确实是agnoster的好看,那就直接换了
换完之后,终端就是这个样子👇:
4.安装颜色库
命令如下👇:
git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git
更换配色方案:
iterm2 -> settings -> Profiles -> Text ->
Colors -> Change Colors -> import ->
iTerm2-Color-Schemes/schemes/全选导入
这里我用的是tokyonight,不是下面这张图所展示,这张图展示的是:Smooooth,但是Argonaut也不错滴。
5.安装插件
命令行高亮
# install
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# write -> ~/.zshrc
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
# explain
${(q-)PWD} 的含义是将当前工作目录的路径作为一个变量,并对该变量进行引号转义,以便在后续的 shell 命令中使用。
# 最终输入结果:
source /Users/pikapi/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
命令自动补全
这个需要自行安装HomeBrew,然后自己找到下载的路径写到zshrc里面。
# install HomeBrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# write -> zsh&bash
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/pikapi/.zshrc
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/pikapi/.bash_profile
# loading local shell
eval "$(/opt/homebrew/bin/brew shellenv)"
# install zsh-autosuggestions
brew install zsh-autosuggestions
# 当然可以通过git安装
# install
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
# edit zsh
vim ~/.zshrc
# vim ~.zshrc
plugins=(git) -> plugins=(git zsh-autosuggestions)
# add source
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# refresh
source ~/.zshrc
6.最终展示
安装Powerlevel9k / Powerlevel10k主题,这个主题实在是太有意思了,我也装一个
# install
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
# vim ~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_MODE="awesome-patched"
# fresh
source ~/.zshrc