Mac终端美化(iterm2+zsh+oh-my-zsh+powerlevel10k)

1,005 阅读1分钟

iterm2+zsh+oh-my-zsh+powerlevel10k

在这里插入图片描述

一、下载iterm2

方式一:官网下载

iterm2.com/

方式二:百度云下载

链接: pan.baidu.com/s/1ZZnTDbVc…

密码:关注公众号 【点九先生】 回复:iterm2 即可获得

二、安装zsh

macos下默认已经安装了zsh,可以直接使用

# 终端输入命令,然后输入密码即可将zsh切换成默认shell $ chsh -s /bin/zsh

三、安装 oh my zsh

  • 使用 curl

sh -c "$(curl -fsSL raw.githubusercontent.com/robbyrussel…)"

  • 使用 wget

sh -c "$(wget raw.githubusercontent.com/robbyrussel… -O -)"

  • 下载源码

## 下载源码 
git clone https://github.com/robbyrussell/oh-my-zsh 
## 执行安装命令 
cd oh-my-zsh/tools sh install.sh

四、下载主题

cd ~/.oh-my-zsh/themes sudo git clone https://github.com/romkatv/powerlevel10k.git

五、下载字体

方式一:官方下载

nerdfonts.com/

找到Downloads,直接下载 Hack 字体,别问我为什么,如果是mac,直接双击安装下载的字体即可安装,然后修改 oh my zsh 的变量文件 ~/.zshrc,修改变量 POWERLEVEL9K_MODE='nerdfont-complete'

方式二:百度云下载

链接: pan.baidu.com/s/1ZZnTDbVc…

密码:关注公众号 【点九先生】 回复:iterm2 即可获得

六、设置字体

在这里插入图片描述

七、下载插件

cd ~/.oh-my-zsh/plugins 
sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git 
sudo git clone git://github.com/zsh-users/zsh-autosuggestions 

八、系统配置

注意export ZSH="/Users/dianjiu/.oh-my-zsh"这里用户名dianjiu改成你的用户名

sudo vim ~/.zshrc
# Prompts
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0C0'
#POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='\uE0C0'
POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0C2'
#POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='\uE0C2'
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir dir_writable vcs virtualenv)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs command_execution_time ip)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_DELIMITER=..
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=$'\n'
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="\uF460%F{073}\uF460%F{109}\uF460%f "
export ZSH="/Users/dianjiu/.oh-my-zsh"
POWERLEVEL9K_MODE='nerdfont-complete'
ZSH_THEME="powerlevel10k/powerlevel10k"
export UPDATE_ZSH_DAYS=13
HIST_STAMPS="yyyy/mm/dd"
plugins=(
    git
    colored-man-pages
    colorize
    github
    brew
    osx
    docker
    docker-compose
    zsh-autosuggestions
    zsh-syntax-highlighting
    autopep8
    python
)
source $ZSH/oh-my-zsh.sh
alias zshconfig="vim ~/.zshrc"
alias vimconfig="vim ~/.vimrc"
alias ansibleconfig="vim ~/.ansible/ansible.cfg"
alias grep='grep --color=auto'
source ~/.zshrc

九、异常处理

问题一:下载插件报错

Cloning into 'zsh-syntax-highlighting'... fatal: unable to access 'https://github.com/zsh-users/zsh-syntax-highlighting.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

问题解决

git config --global http.postBuffer 4194304000
sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git 
Password: 
Cloning into 'zsh-syntax-highlighting'... remote: Enumerating objects: 6913, done. remote: Total 6913 (delta 0), reused 0 (delta 0), pack-reused 6913 Receiving objects: 100% (6913/6913), 1.45 MiB | 64.00 KiB/s, done. Resolving deltas: 100% (4675/4675), done.

问题二:vscode终端字体乱码

在setting.json中新增

"terminal.integrated.fontFamily": "Hack Nerd Font",

十、参考文献

www.jianshu.com/p/609c1f554…

www.jianshu.com/p/7162c4b7a…