LoginSignup
15
14

More than 5 years have passed since last update.

Powerlineをちょっと試したい人のために

Last updated at Posted at 2017-05-31

image.png
from: oh-my-zsh themes

Powerline

ターミナルのステータスラインをめちゃんこかっこいいやつにするプラグイン

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

この辺から入信してください。

とりあえず導入

まずはとりあえず検索にひっかかった次の記事にお世話になる。

5分でターミナルの表示をカッコよくする

私はこれを流して、フォントがインストールできなかった。

ので、新・フローを提示す。

  1. $ git clone https://github.com/banga/powerline-shell.git
  2. $ cd /path/to/powerline.git
  3. $ ./install.py
  4. $ ln -s /path/to/powerline-shell.py ~/powerline-shell.py
  5. put following code in your .bashrc
function _update_ps1() {
    PS1="$(~/powerline-shell.py --mode compatible $? 2> /dev/null)"
}

if [ "$TERM" != "linux" ]; then
    PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

ポイントは 2行目の ~powerline-shell.py --mode compatible
--mode compatibleをつけることでpowerline対応のフォントをインストールしなくとも、お豆腐 ᫀ がターミナルに現れることがない。

  1. $ bash

とりあえずこれでpowerlineがbashで動く

powerlineをzshやfishで動かす

普段からzshやfishを使っている人は、次のコードをそれぞれ.zshrcconfig.fishに記述する。

--mode compatibleはお好みで。

zsh (~/.zshrc)

function powerline_precmd() {
    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)
}

if [ "$TERM" != "linux" ]; then
    install_powerline_precmd
fi

fish (~/.config/fish/config.fish)

# overwrite `fish_prompt`
function fish_prompt
    ~/powerline-shell.py $status --shell bare ^/dev/null
end
15
14
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
15
14