zsh[Oh My Zsh]

iTerm2 中对于分支的显示方案并不是很人性化。通过安装 Oh-My-Zsh 对分支控制了然于胸。
本篇文章主要介绍 Oh-My-Zsh 的安装以及主题搭配方案。感兴趣的同学可以参照着配置自己喜欢的主题样式

安装


1
2
3
4
5
6
7
8
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
# Backup your existing ~/.zshrc file: optional
cp ~/.zshrc ~/.zshrc.orig
# Recommend
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
source ~/.zshrc
# Change your default shell
chsh -s /bin/zsh

主题配置


采用的是powerlevel9k主题,色系是Neutron

以下是安装 powerline 以及解决字体乱码问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pip install --user powerline-status

# Download fonts and font config.
wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf

# Linux
mv PowerlineSymbols.otf ~/.fonts/
# Update font cache for the path the font was moved to.
fc-cache -vf ~/.fonts/
# Install the fontconfig file.
mv 10-powerline-symbols.conf ~/.config/fontconfig/conf.d/

# Mac OS X
# You can click the PowerlineSymbols.otf to install or you can move the file to font dir like:
mv PowerlineSymbols.otf /Library/Fonts/

字体安装完毕之后,需要:

配置色系

  • Launch iTerm 2. Get the latest version at iterm2.com
  • Type CMD+i (⌘+i)
  • Navigate to Colors tab
  • Click on Load Presets
  • Click on Import
  • Save the neutron.itermcolors file
  • Click on Load Presets and choose neutron

配置字体

  • Navigate to Text tab
  • Click Change Font
  • Search PowerlineSymbols and select to use

样式配置(在~/.zshrc中添加):

1
2
3
4
5
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status time)
POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S}"
POWERLEVEL9K_NODE_VERSION_BACKGROUND='022'
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1

更多可参看: 主题色系

ps: 由于 git 是默认安装的插件,而且 ~/.zshrc 中是默认的高亮,满足了基本使用。如果需要安装插件,请自行 google 。刚接触的时候,迷恋插件,然后找到 Github 上的脚本安装,将 Vim 打造成了炫酷的 IDE 效果,由于不熟悉操作,放弃之,自此远离非必要插件,需求驱动安装插件我觉得是新手最佳选择.