安装oh my zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
安装PowerLine
pip3 install powerline-status --user
安装PowerFonts
新建一个文件夹,如:~/Desktop/OpenSource/
# git clone
git clone https://github.com/powerline/fonts.git --depth=1
# cd to folder
cd fonts
# run install shell
./install.sh
安装好字体库之后,我们来设置iTerm2的字体,具体的操作是iTerm2 -> Preferences -> Profiles -> Text,在Font区域选中Change Font,然后找到Meslo LG字体。有L、M、S可选
安装iTerm2主题Toychest
git clone https://github.com/mbadolato/iTerm2-Color-Schemes
然后打开 偏好设置->profile->color, 找到 color presets 里面的 import 就可以选择 Toychest 进行导入了。导入成功后,还需要手动选择它,才会生效。
安装Oh-my-zsh主题
cd ~/Desktop/OpenSource
git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git
cd oh-my-zsh-agnoster-fcamblor/
./install
vi ~/.zshrc
将ZSH_THEME后面的字段改为agnoster
安装高亮插件和命令补全插件
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/zsh-users/zsh-autosuggestions
vi ~/.zshrc
在配置文件内添加
plugins=(zsh-autosuggestions)
plugins=(zsh-syntax-highlighting)
zsh-syntax-highlighting要在底部,然后在文件最底部添加
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/.zshrc
其他技巧
隐藏用户名
编辑vim ~/.zshrc文件,增加DEFAULT_USER=”raylen”配置,示例:
vi ~/.zshrc
DEFAULT_USER="raylen"
# 可以通过whoami查看当前用户名
隐藏主机名
在~/.zshrc
文件最底部加上如下代码
###以下内容是终端只显示姓名,不显示主机名
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
fi
}
可能遇到的问题
[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxrwx 7 hans admin 238 2 9 10:13 /usr/local/share/zsh
解决方案:
chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions