效果图
实际上我主要用powerline来美化或加强了两个东西,分别是zsh和vim而这两个是需要安装不同的powerline的,搜索的话,一个是powerline-shell,一个是powerline或vim-powerline,安装后,效果如下图:
这个是zsh里的效果
这个是在macvim里的效果
安装与配置
1. zsh
官网:http://ohmyz.sh/,简单介绍下,就是开源的shell扩展,让你的shell支持高亮,git,快速跳转什么的,因为要做sh终结者,所以是z
两各安装方式,需先安装git,安装完后,重启终端搞定
curl -L http://install.ohmyz.sh | sh
wget --no-check-certificate http://install.ohmyz.sh -O - | sh
2. powerline-shell
官网:https://github.com/milkbikis/powerline-shell,github的说明已经很清楚了,步骤大体如下:
- git clone https://github.com/milkbikis/powerline-shell,先clone到一个文件里
- 将文件夹中的config.py.dist复制更名为config.py
- ./install.py,安装
- ln -s <path/to/powerline-shell.py> ~/powerline-shell.py,在主目录下创建link,或将其到path,好吧,我上面那个还在。。
- pip install argparse,python2.6安装这个
- 然后,修改zsh的配置文件.zshrc,在最后添加如下内容,完成后,用source .zshrc更新配置即可
function powerline_precmd() {
export PS1="$(~/powerline-shell.py $? --shell zsh 2> /dev/null)"
}
function install_powerline_precmd() {
for s in "${precmd_functions[@]}"; do
if [ "$s" = "powerline_precmd" ]; then
return
fi
done
precmd_functions+=(powerline_precmd)
}
install_powerline_precmd
- 最后,出现乱码的情况下,安装字体https://github.com/Lokaltog/powerline-fonts,然后在终端的偏好设置里更改字体就可以了
3. 安装macvim
官网:https://github.com/b4winckler/macvim,安装过程如下,其实就一条命令,需先安装有brew,brew的安装方法就不说了啊
brew install macvim --env-std --override-system-vim
安装完成之后,我也郁闷了,安装上了吗,怎么启动呢。。嘻嘻,直接敲mvim就可以了,好像第一次启动后会默认帮你把默认的vim链到这个上,然后,以后直接vim也是mvim了,这里再说一下吧,个人不太建议再在macvim上装太多的插件什么的,如侧边文件目录,各种快捷操作,配色什么的,一句话说就是:我不想花很大的力气,把macvim打扮成sublime,还增加了操作的记忆负担,而且还会减慢启动速度。所以我让它还是vim,就是好看一点,好用一些就行了
4. 安装powerline(vim)
官网:http://powerline.readthedocs.org,里面有安装过程,但我安装完后,不太一样没有script文件夹,所以又从github里弄了一份,步骤如下:
- pip install --user git+git://github.com/Lokaltog/powerline,没错,还是一条命令。。但需要先安装pip
- pip install -e --user {path_to_powerline},会为用户创建快捷方式到.local/bin里,不行的话就自己创建,如果这两步不通的话,可以按下面的做
- https://github.com/Lokaltog/powerline,用git clone出这个官网项目的源码到一个目录中
- 修改~/.vimrc,没有的话,自己创建,上面两个方式都需要你知道powerline的目录,配置里会用到,配置如下:
set rtp+=/Users/cungen/sdk/system/powerline/powerline/bindings/vim
set guifont=Sauce\ Code\ Powerline:h14.5
set laststatus=2
set encoding=utf-8
set t_Co=256
set number
set fillchars+=stl:\ ,stlnc:\
set term=xterm-256color
set termencoding=utf-8
set background=light
注意,要将目录改为你安装powerline的目录,字体改成你要使用的字体,也需是从powerline的字体里下载的字体,保存后,source .vimrc使用配置生效,再次启动vim,即可哈哈。。