Powerlineを入れるとずいぶん見た目が美しくなるそうなので入れてみました。
NeoBundleインストール
Shougo/neobundle.vim
% curl https://raw.githubusercontent.com/Shougo/neobundle.vim/master/bin/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1948 100 1948 0 0 6421 0 --:--:-- --:--:-- --:--:-- 6429
git is /usr/local/bin/git
Start fetch NeoBundle...
Cloning into '/Users/wnoguchi/.vim/bundle/neobundle.vim'...
remote: Counting objects: 6770, done.
remote: Total 6770 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6770/6770), 1.65 MiB | 269.00 KiB/s, done.
Resolving deltas: 100% (2859/2859), done.
Checking connectivity... done.
Done.
Please write NeoBundle initial setting to your vimrc path ...
"NeoBundle Scripts-----------------------------
if has('vim_starting')
set nocompatible " Be iMproved
" Required:
set runtimepath+=/Users/wnoguchi/.vim/bundle/neobundle.vim/
endif
" Required:
call neobundle#begin(expand('/Users/wnoguchi/.vim/bundle'))
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" My Bundles here:
NeoBundle 'Shougo/neosnippet.vim'
NeoBundle 'Shougo/neosnippet-snippets'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'flazz/vim-colorschemes'
" You can specify revision/branch/tag.
NeoBundle 'Shougo/vimshell', { 'rev' : '3787e5' }
" Required:
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
"End NeoBundle Scripts-------------------------
Done.
Complete setup NeoBundle!
vimrcに追記
"NeoBundle Scripts-----------------------------
if has('vim_starting')
set nocompatible " Be iMproved
" Required:
set runtimepath+=/Users/wnoguchi/.vim/bundle/neobundle.vim/
endif
" Required:
call neobundle#begin(expand('/Users/wnoguchi/.vim/bundle'))
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" My Bundles here:
NeoBundle 'Shougo/neosnippet.vim'
NeoBundle 'Shougo/neosnippet-snippets'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'flazz/vim-colorschemes'
" You can specify revision/branch/tag.
NeoBundle 'Shougo/vimshell', { 'rev' : '3787e5' }
" Required:
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
"End NeoBundle Scripts-------------------------
vimを立ち上げて :NeoBundleInstall コマンドを実行
まずは質問に y
と答える。
% vi
Not installed bundles: ['vimshell', 'ctrlp.vim', 'vim-colorschemes']
Press ENTER or type command to continue
Install bundles now?
(y)es, [N]o: y
[neobundle/install] Update started: (2014/08/09 22:54:13)
[neobundle/install] (1/3): |vim-colorschemes| git clone --recursive https://github.com/flazz/vim-colorschemes.git "/Users/wnoguchi/.vim/bundle/vim-colorschemes"
[neobundle/install] (2/3): |ctrlp.vim| git clone --recursive https://github.com/kien/ctrlp.vim.git "/Users/wnoguchi/.vim/bundle/ctrlp.vim"
[neobundle/install] (3/3): |vimshell| git clone --recursive https://github.com/Shougo/vimshell.git "/Users/wnoguchi/.vim/bundle/vimshell_3787e5"
[neobundle/install] (1/3): |vim-colorschemes| Updated
[neobundle/install] |vim-colorschemes| -> 36ab747f27be95d9f5ebc2439124cddad52763be
[neobundle/install] (2/3): |ctrlp.vim| Updated
[neobundle/install] |ctrlp.vim| -> b5d3fe66a58a13d2ff8b6391f4387608496a030f
[neobundle/install] (3/3): |vimshell| Locked
[neobundle/install] (3/3): |vimshell| git checkout 3787e5
[neobundle/install] (3/3): |vimshell| Updated
[neobundle/install] |vimshell| -> 3787e52766812d8b99a93ccdda57517bc2a0bab6
[neobundle/install] Installed/Updated bundles:
vim-colorschemes
ctrlp.vim
vimshell
[neobundle/install] Update done: (2014/08/09 22:54:39)
Press ENTER or type command to continue
エディタが開いたら :NeoBundleInstall
コマンドを叩く。
:NeoBundleInstall
そして出力が以下。
[neobundle/install] Target bundles not found.
[neobundle/install] You may have used the wrong bundle name, or all of the bundles are already installed.
Press ENTER or type command to continue
インストールするものは何もない、あんたが書いたbundle名は間違ってるかすでに入っていると言われた。
さっきので y
って答えたからもう全部入ってるのかな・・・。
Powerline入れる
.vimrc
に以下を追記。
NeoBundle Scripts
から End NeoBundle Scripts
の間に書くのがミソ。
"NeoBundle Scripts-----------------------------
NeoBundle 'alpaca-tc/alpaca_powertabline'
NeoBundle 'Lokaltog/powerline', { 'rtp' : 'powerline/bindings/vim'}
NeoBundle 'Lokaltog/powerline-fontpatcher'
"End NeoBundle Scripts-------------------------
:source ~/.vimrc
するか vim を立ち上げて
:NeoBundleInstall
powerline
[neobundle/install] Update done: (2014/08/09 23:03:39)
Press ENTER or type command to continue
フォントにパッチ当てる
けっこうかかる。SSDならすこしはやい。
brew install fontforge --with-python
インストールしたフォントをホームディレクトリにコピーしてくる
Rictyなんてフォントねーな・・・って思ってぐぐってみたらプログラミング用のフォントとして超有名なフォントなんですね・・・。
フォントとオーディオはほんと宗教みたいな世界ですわ。
さっそくインストール。
フォントRictyのインストール
Inconsolata入れる
Inconsolata
Open Type file を入れる。
sudo wget -O /System/Library/Fonts/Inconsolata.otf http://levien.com/type/myfonts/Inconsolata.otf
M+とIPAの合成フォント入れる
M+とIPAの合成フォント
Miguを入れる。MigMixじゃない方。
とりあえず全部ダウンロードした。
migu-1c-bold.ttf
migu-1c-regular.ttf
migu-1m-bold.ttf
migu-1m-regular.ttf
migu-1p-bold.ttf
migu-1p-regular.ttf
migu-2m-bold.ttf
migu-2m-regular.ttf
これらを
/System/Library/Fonts/
に突っ込む。
git clone https://github.com/yascentur/Ricty.git
cd /System/Library/Fonts/
sudo /path/to/ClonedRictySources/ricty_generator.sh auto
Ricty Generator 3.2.3
Author: Yasunori Yusa <lastname at save.sys.t.u-tokyo.ac.jp>
This script is to generate ``Ricty'' font from Inconsolata and Migu 1M.
It requires 2-5 minutes to generate Ricty. Owing to SIL Open Font License
Version 1.1 section 5, it is PROHIBITED to distribute the generated font.
Generate modified Inconsolata.
Find ./Inconsolata.otf.
Save Modified-Inconsolata-Regular.sfd.
While making Inconsolata bold, wait a little...
Save Modified-Inconsolata-Bold.sfd.
Generate modified Migu 1M.
Find ./migu-1m-regular.ttf.
While scaling migu-1m-regular.ttf, wait a little...
Save Modified-migu-1m-regular.sfd.
Find ./migu-1m-bold.ttf.
While scaling migu-1m-bold.ttf, wait a little...
Save Modified-migu-1m-bold.sfd.
Generate Ricty.
While merging Modified-Inconsolata-Regular.sfd with Modified-migu-1m-regular.sfd, wait a little...
Save Ricty-Regular.ttf.
Remove temporary files.
Generate RictyDiscord-Regular.ttf.
Generate RictyDiscord-Bold.ttf.
Succeeded in generating Ricty!
sudoで実行しないと、パーミッション不足でSave Ricty-Regular.ttf.とかいいつつ保存されないので注意。
% ls /System/Library/Fonts/Ricty*
/System/Library/Fonts/Ricty-Bold.ttf
/System/Library/Fonts/Ricty-Regular.ttf
/System/Library/Fonts/RictyDiscord-Bold.ttf
/System/Library/Fonts/RictyDiscord-Regular.ttf
あーなれない作業で長かった・・・。
Powerline用フォントにパッチを当てる作業に戻る
フォントにパッチ当てて /System/Library/Fonts/
ディレクトリに生成する。
Qiitaの記事とは微妙にパスを読み替えてる。
パッチは当てるけど、元のファイルが上書きされるわけじゃないから安心だね。
カレントディレクトリに成果物が生成されるので注意。
本当はシステムのディレクトリは汚したくないから ~/.fonts/
に入れたいんだけど、
サーチパスの設定が足りないのかな。
あと、僕の環境だと1種類だけパッチ当てても全然候補に出てこないから全部パッチあてて変換しました。
% cd /var/tmp
% mkdir fontwork
% cd fontwork
% find /System/Library/Fonts/ -name "Ricty*.ttf" | xargs fontforge -lang=py -script ~/.vim/bundle/powerline-fontpatcher/scripts/powerline-fontpatcher
(snip)
Copyright (c) 2000-2012 by George Williams.
Executable based on sources from 14:57 GMT 31-Jul-2012-D.
Library based on sources from 14:57 GMT 31-Jul-2012.
This font contains both a 'mor[tx]' table and a 'GSUB' table.
FF will only read feature/settings in 'morx' which do not match features
found in 'GSUB'.
どんなのが生成されたか見てみる。
% ls
Ricty Bold for Powerline.ttf
Ricty Discord Bold for Powerline.ttf
Ricty Discord Regular for Powerline.ttf
Ricty Regular for Powerline.ttf
システムフォントディレクトリに移動。
sudo mv * /System/Library/Fonts/
for Powerlineというフォントが作成されてる。
キャッシュ作成。
% sudo fc-cache -vf
【Linux Mint, vim】vim-powerlineにフォントRictyのパッチをあてる – i’ll be fine
vimでPowerlineの設定
最後にstatuslineの表示設定を .vimrc
に書き加える。
" statusline表示
set laststatus=2
" Powerlineの設定
let g:Powerline_symbols = 'fancy'
"文字化けするならこっち使う
"let g:Powerline_symbols = 'compatible'
set t_Co=256
iTerm2の設定
まだ終わりじゃない。
Mac標準のターミナルを使っている人はそれの設定を、僕はiTerm2を使っているのでフォントの設定をする。
これやらずにvimのstatuslineの表示(矢印とか盛大に化けてる)が崩れてなんでだろうと小一時間悩みました。
ものすごく基本的なことなのに、パッチ当てたPowerline用のフォント指定しないとうまく表示されるわけがないよね。。。
まずiTerm2のPreferencesを開きます。
いろいろ微調整するのでプロファイルは複製したほうがいいと思います。

フォントの設定を開きます。
以下のフォント設定を施します。
- Regular Font: Inconsolate, Regular, 14pt
- Non-ASCII Font: Ricty for Powerline, Regular, 14pt

Regular FontにInconsolateを選択したのはRictyフォントだとBold書体が滲んで表示されて見にくいからです。
さらに、デフォルトだとvimを開いた時にstatuslineのフォントのサイズと三角矢印のいちがズレていて許せないので、Non-ASCII FontのCharacter SpacingセクションのVertical, Horizontalの微調整をします。
ようやく終わりです・・・。
適当なリポジトリ配下にあるソースファイルを開いてみます。

感動・・・。
References
- Vim – powerlineをいつ使う?今でしょ! – Qiita
- tmux-powerline – Qiita
- Lokaltog/powerline