分享技术 · 探索极限 · Code is Art
▣ 2016-07-20 ◉ 929 开发工具

macOS 下 zsh 与 Vim 的 Powerline 配置

zsh 的 Powerline 配置

首先需要安装 pip。

easy_install pip

如果系统是 macOS 10.11 以上,旧方案可能需要关闭 SIP。现在不建议长期关闭 SIP,这里仅保留当时记录。

csrutil disable
csrutil status

安装 Powerline

pip install powerline-status
pip show powerline-status

在 zsh 配置文件中添加执行脚本,路径按实际安装位置调整。

vim ~/.zshrc
. /Library/Python/2.7/site-packages/powerline/bindings/bash/powerline.sh

安装 Powerline 字体

git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh

安装完成后,将终端字体修改为带 Powerline 补丁的字体。


Vim 相关配置

为 Vim 配置 Powerline 时,需要确认 Vim 编译时启用了 Python 支持。如果没有,可以通过 Homebrew 重新安装 Vim 或 MacVim。

brew install vim --with-python --with-ruby --with-perl
brew install macvim --env-std --override-system-vim

然后在 ~/.vimrc 中加入以下配置,路径按实际情况调整。

set rtp+=/Library/Python/2.7/site-packages/powerline/bindings/vim
set nocompatible
set t_Co=256

let g:minBufExplForceSyntaxEnable = 1
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup

if !has('gui_running')
    set ttimeoutlen=10
    augroup FastEscape
        autocmd!
        autocmd InsertEnter * set timeoutlen=0
        autocmd InsertLeave * set timeoutlen=1000
    augroup END
endif

set laststatus=2
set guifont=Inconsolata for Powerline:h14
set noshowmode

发表回复