CentOS 7 安裝 Powerline 與設定 C Shell 環境筆記

Introduction

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.

powerline── powerline

雖然透過 PIP 安裝 Powerline 極為方便,然而 CentOS 7 下安裝並使用於 C Shell 時會有一些小細節與問題需要注意,本篇文章將紀錄如何由 CentOS 7 下安裝 Powerline 並成功應用於 C Shell 下。

Installation

Basic

在安裝 Powerline 前,我們必須先安裝 PIP:

1
2
$ sudo yum --enablerepo=extras install epel-release
$ sudo yum install python-pip

安裝完畢後再根據官方文件所提供的指令進行安裝 Powerline:

1
$ sudo pip install powerline-status

接著補充所需要的字型:

1
2
3
4
5
$ sudo wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
$ sudo wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf
$ sudo mv PowerlineSymbols.otf /usr/share/fonts/
$ sudo fc-cache -vf /usr/share/fonts/
$ sudo mv 10-powerline-symbols.conf /etc/fonts/conf.d/

最後修改 ~/.bashrc 檔案便完成 Bash 的設定:

1
2
3
4
5
$ vi ~/.bashrc
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh

powerline-bash

Fix C Shell Environment

在 C Shell 下,我們要修改下載下來的原始檔案,否則當使用 C Shell 時,畫面會出現一些訊息:

powerline-csh-1

首先開起 powerline.tcsh 並對第 9 行與第 31 行進行編輯:()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$ sudo vi /usr/lib/python2.7/site-packages/powerline/bindings/tcsh/powerline.tcsh

...
set POWERLINE_SOURCED=($_)
if ! $?POWERLINE_CONFIG_COMMAND then
#if ( { which powerline-config > /dev/null } ) then
if "`command -v powerline-config`" != "" then
set POWERLINE_CONFIG_COMMAND="powerline-config"
else
set POWERLINE_CONFIG_COMMAND="$POWERLINE_SOURCED[2]:h:h:h:h/scripts/powerline-config"
endif
else
...
endif
if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses tmux } ) then
if ( $?TMUX_PANE ) then
...
else
#set _POWERLINE_TMUX_PANE="`tmux display -p '#D'`"
set _POWERLINE_TMUX_PANE=""
endif
...
endif
...

最後將環境加入至 ~/.tcshrc 便完成設定:

1
$ echo 'source /usr/lib/python2.7/site-packages/powerline/bindings/tcsh/powerline.tcsh' | tee -a ~/.tcshrc

powerline-csh-2

References