LoginSignup
95
86

More than 5 years have passed since last update.

Powerline 系なんかうまくいかないなーとずっと思ってたので改めてちゃんとやった

Last updated at Posted at 2015-01-17

はよ

これ読む。

Powerline — Powerline beta documentation

まえおき

vim や tmux や zsh の powerline、みんなの様子をみているときれいにできてるのに、それなにオレもやりたいとなって試すと、
フォントずれるとか、文字化けするとか、とにかく動かないとか、動くけどなんかちがうとか、なくてもべつに困らないし、とかで毎回あきらめていた。

powerline、元は vim 用だけだった記憶があるんだけど、
bash や zsh の prompt 用、 tmux 用、 emacs 用、とか
みんなそれぞれ思い思いの powerline を公開しはじめ (適当な予想)、
それらがいつの間にかぜんぶ powerline/powerline に統合されていた。

powerline/powerline
Powerline is a statusline plugin for vim,
and provides statuslines and prompts for several other applications,
including zsh, bash, tmux, IPython, Awesome and Qtile.

erikw/tmux-powerline とかは、今は README にでかでかと DEPRECATION WARNING と書いてある (親切)

erikw/tmux-powerline
tmux-powerline, with all other powerline projects, is replaced by the new unifying powerline.

README の commit を見た感じだと2年くらい前には統合の動きがあったぽい。

Added deprecation warning. Fixes #128 · 9b840c9 · erikw/tmux-powerline

tmux の powerline うまくいかないなーとやってたのはもうちょっと前なので、なるほどと思った。

powerline 入れる

Pip installation をみて進めていく。

必要な環境については Generic requirements を確認する。

pyenv で python 2.7.9 を入れてた ので、次のやり方でインストールした。

$ pip install --user git+git://github.com/powerline/powerline

powerline を動かしてみたとき、これのインストール足りてないのでは、みたいなこと言われることがある。

powerline では各表示モジュールを Segments と呼ぶぽいけど、

CPU 使用率とかを表示する segment で psutil を利用してるらしく、これないぜと言われたので入れた。

$ pip install psutil

powerline patched fonts 入れる

powerline/fonts

zip download なり git clone なりして
./install.sh するとフォント全部一括インストール。

使いたいフォントだけ個別に Font Book.app とかでインストールしてもOK。

当然だけど erikw/tmux-powerline でこのフォントを使おうとすると、
◎ みたいなのが表示されるだけでなにこれとなる。

tmux を powerline する

iTerm2 で tmux 使う、 powerline する。

iTerm2 設定

iTerm2 Preferences - Profiles - Text で powerline patched なフォントを設定する。

  • Regular Font
    • 14pt Sauce Code Powerline
  • Non-ASCII Font

    • 16pt Sauce Code Powerline
      • フォントサイズてきとうに調節した
  • Double-Width Characters: Treat ambiguous-width characters as double width

tmux 設定

${HOME}/.local/bin に PATH が通っている必要がある。

~/.tmux.conf に以下を追記する。

~/.tmux.conf
run-shell "powerline-daemon -q"
source ~/.local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf

zsh prompt を powerline する

~/.zshrc
. ~/.local/lib/python2.7/site-packages/powerline/bindings/zsh/powerline.zsh

vim を powerline する

~/.vimrc
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup

set laststatus=2 " Always display the statusline in all windows
set showtabline=2 " Always display the tabline, even if there is only one tab
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)

各種設定する

Forking the main GitHub repo is not needed to personalize Powerline configuration!
Please read through the Quick setup guide for a quick introduction to user configuration.

なるほど Quick setup guide - Configuration and customization — Powerline beta documentation

$ mkdir ~/.config/powerline 
$ cp -R ~/.local/lib/python2.7/site-packages/powerline/config_files/* ~/.config/powerline/ 

weather

天気の表示なくていいんだけど、どんなかんじか見てみたかった。

~/.config/powerline/themes/powerline.json
@@ -87,7 +87,8 @@
  "powerline.segments.common.wthr.weather": {
    "args": {
      "icons": {
        "day":           "〇",
        "blustery":      "⚑",
        "rainy":         "☔",
        "cloudy":        "☁",
        "snowy":         "❅",
        "stormy":        "☈",
        "foggy":         "≡",
        "sunny":         "☼",
        "night":         "☾",
        "windy":         "☴",
        "not_available": "�",
        "unknown":       "⚠"
-     }
+     },
+     "location_query": "tokyo, japan"
    }
  },
~/.config/powerline/themes/tmux/default.json
@@ -15,14 +15,17 @@
      {
        "function": "powerline.segments.common.time.date",
        "name": "time",
        "args": {
          "format": "%H:%M",
          "istime": true
        }
      },
      {
+       "function": "powerline.segments.common.wthr.weather"
+     },
+     {
        "function": "powerline.segments.common.net.hostname"
      }

95
86
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
95
86