zsh命令行工具安装教程

安装

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

安装插件

命令检查高亮插件

1
2
3
4
5
6
7
8
9
10

$ cd ~/.oh-my-zsh/custom/plugins/

$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

$ vim ~/.zshrc

# 然后在plugin添加 plugins=(git vscode zsh-syntax-highlighting autojump zsh-autosuggestions sudo last-working-dir web-search)
# 主题修改 ZSH_THEME="agnoster"
$ source ~/.zshrc

安装字体

1
2
3
4
5
6
7
8
9
10
11
$ pip3 install powerline-status

$ git clone https://github.com/powerline/fonts.git --depth=1

# 安装
$ cd fonts
$ ./install.sh

# 安装完删除下载的原始包
$ cd ..
$ rm -rf fonts

安装item2

选择 iTerm2->Preferences->Profiles->Text->勾选Use a different font for non-ASCII text->选择字体Meslo

vscode 中修改编辑器主题,终端字体及颜色

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!-- settings.json -->

"workbench.colorTheme": "Quiet Light",
"terminal.integrated.fontFamily": "Meslo LG L for Powerline",
"workbench.colorCustomizations": {
// "terminal.background": "#dfdfdf",
// "terminal.foreground": "#dddad6",
"terminal.ansiBlack": "#fcfcfc",
"terminal.ansiBrightBlack": "#323232",
"terminal.ansiBrightBlue": "#0D6678",
"terminal.ansiBrightCyan": "#8BA59B",
"terminal.ansiBrightGreen": "#237e02",
"terminal.ansiBrightMagenta": "#8F4673",
"terminal.ansiBrightRed": "#d55a49",
"terminal.ansiBrightWhite": "#d2c78a",
"terminal.ansiBrightYellow": "#dfaf3e",
"terminal.ansiCyan": "#67ac92",
"terminal.ansiMagenta": "#8F4673",
"terminal.ansiRed": "#cb5849",
"terminal.ansiWhite": "#c2924f",
"terminal.ansiYellow": "#d2a53e",
"terminal.ansiGreen": "#48b122",
"terminal.ansiBlue": "#238cc4"
}

zsh导致的nvm不可用问题

修改 ~/.bash_profile 添加一下内容

1
2
3
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

取消显示终端里面的设备名

找到zsh当前主题文件的路径,例如: /Users/attacki/.oh-my-zsh/themes/agnoster.zsh-theme

修改主题文件里面的字符模板,字符模板里的 @%m,就可以取消显示设备号

1
2
3
4
5
prompt_context() {
if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)%n"
fi
}