---
title: "[转]vim-airline in xshell or putty or MobaXterm"
author: "jack_boy"
date: "2014-11-11T13:36:53Z"
tags: []
categories: ["操作系统"]
slug: "vim-airline-in-xshell-or-putty-or-mobaxterm"
draft: false
lastmod: "2016-03-23T12:36:14Z"
id: 2154511
url: "https://jack-boy.iteye.com/blog/2154511"
---

windows下使用Xshell，putty或者是MobaXterm时，vim-airline插件的bottom bar可能显示不好，主要是字体的问题，正确的安装字体后能解决问题。
[powerline字体下载]('https://codeload.github.com/powerline/fonts/zip/2015-12-04')

安装完字体后，设置终端的字体为DejaVu Sans Mono for Powerline
打开.vimrc文件，:help airline，跳到airline-customization，拷贝能正常显示的symbols到vimrc中，重新打开vim底部的状态条就显示正常了。

同时，oh-my-zsh的很多theme也显示正常。


https://github.com/bling/vim-airline 是一个非常不错的状态显示工具

前段时间装好了airline插件，但是没呈现应有的效果，原因是没有安装字体。根据官网的提示需要安装powerline的字体，我便照着powerline官网的配置方法来，但是还是没有成功。其原因是我安装了patched fonts，但是没有将terminal的font设置为patched fonts中的一种，所以statusbar会有乱码。下面对安装patched fonts做一个小结。

**一、Ubuntu12.04 下**

1.Download patched fonts

$mkdir ~/.fonts新建一个font文件夹，然后$cd ~/.fonts进入.fonts文件夹。

$git clone git@github.com:Lokaltog/powerline-fonts.git
将powerline的patched fonts拷贝到~/.fonts目录下，

2.Install the patched fonts to your System

运行$fc-cache -vf ~/.fonts安装patched fonts到系统中

3.Set Terminal fonts

设置Terminal字体非常重要，我初次配置时，安装patched fonts，但是由于没有set terminal font,所以statusbar显示乱码。设置方法如下：

Edit——Profiles——Default(Edit)——General——Font，选择~/.fonts/powerline下的某一种即可(可选范围一定要在刚才下载的patched fonts中选一种，否则乱码。)，当然也可以采取powerline font installing中的另一种方式，不过我没做尝试，有兴趣的朋友try it。

**二、Mac OS X 下**

1.Download patched fonts

$git clone git@github.com:Lokaltog/powerline-fonts.git ~/Library/Fonts/powerline-fonts
2.Install the patched fonts to your Systewa

打开字体册应用程序，添加下载的字体即可

3.Set Terminal fonts or Set Macvim fonts

iterm2下设置字体：

iTerm->Preferences->Profile->Texts

选择poweline的一种字体

如果使用的是Macvim,那么终端设置的字体与airline显示无关，需要在macvim中设置字体。

Macvim下设置字体：

if has("gui_running")
    set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h14 //powerline字体
endif
FAQ

**显示git分支**

安装vim-fugitive git外包插件即可

Bundle 'tpope/vim-fugitive'
设置airline主题

let g:airline_theme="solarized"
airline状态栏不实现

set laststatus=2
airline没有颜色显示

set t_Co=256       " Explicitly tell Vim that the terminal supports 256 colors
<span style="color:red">注：此处是重点，要在xshell或putty中显示颜色，必需要设置这个选项，经过试验</span>

**参考**
vim安装airline插件<http://chinacheng.iteye.com/blog/1935564>
vim-airline FAQ wiki<https://github.com/bling/vim-airline/wiki/FAQ>

转自vim-airline安装配置<http://www.junevimer.com/2014/11/03/vim-airline.html>