如何安装和使用powerline插件?
Powerline是一个插件,用于显示bash,zsh的vim,tmux和shell提示符的信息和美观状态。
Vim状态栏 : 如何在Ubuntu中为不同的应用程序和shell安装和设置Powerline?
插件安装:
安装python-pip
和git
:按Ctrl + Alt + T打开终端并运行:
sudo apt-get install python-pip git
-
每位用户:
在终端运行中:pip install --user git+git://github.com/Lokaltog/powerline
通过使用您喜欢的编辑器修改
~/.profile
,将~/.local/bin
添加到$PATH
:gksudo gedit ~/.profile
并在其末尾添加以下行:
if [ -d "$HOME/.local/bin" ]; then PATH="$HOME/.local/bin:$PATH" fi
-
系统范围:
在终端运行中:su -c 'pip install git+git://github.com/Lokaltog/powerline'
字体安装:
Powerline提供了两种安装所需字体的方法。 如果您正在使用以下终端之一: Gnome Terminal
, Konsole
, lxterminal
, st
, Xfce Terminal
, Terminator
, Guake
, Yakuake
那么您应该使用“Fontconfig”方法。
-
Fontconfig 🙁推荐)
-
每位用户:
在终端中运行以下命令:wget https://github.com/Lokaltog/powerline/raw/develop/font/PowerlineSymbols.otf https://github.com/Lokaltog/powerline/raw/develop/font/10-powerline-symbols.conf mkdir -p ~/.fonts/ && mv PowerlineSymbols.otf ~/.fonts/ fc-cache -vf ~/.fonts mkdir -p ~/.config/fontconfig/conf.d/ && mv 10-powerline-symbols.conf ~/.config/fontconfig/conf.d/
-
系统范围:
在终端中运行以下命令:wget https://github.com/Lokaltog/powerline/raw/develop/font/PowerlineSymbols.otf https://github.com/Lokaltog/powerline/raw/develop/font/10-powerline-symbols.conf sudo mv PowerlineSymbols.otf /usr/share/fonts/ sudo fc-cache -vf sudo mv 10-powerline-symbols.conf /etc/fonts/conf.d/
-
-
补丁字体:
仅当“Fontconfig”方法不适合您或您使用的是上述以外的终端时,才使用此方法。- 从powerline-fonts下载您选择的字体 。
- 对于每个用户安装,将修补后的字体移动到
~/.fonts/
,或者将/usr/share/fonts
到系统范围的安装。 - 运行
fc-cache -vf ~/.fonts
来更新字体缓存,sudo fc-cache -vf
在系统范围内执行。
要在Gvim
使用修补字体,请参阅此答案并更改相应终端的字体,请检查以下问题: 如何更改各种终端仿真程序的字体? 。 您可能必须在安装字体后重新启动系统才能使更改生效。
用法:(对于每个用户安装)
-
Vim状态栏:
在~/.vimrc
或/etc/vim/vimrc
添加以下内容:set rtp+=$HOME/.local/lib/python2.7/site-packages/powerline/bindings/vim/ " Always show statusline set laststatus=2 " Use 256 colours (Use this setting only if your terminal supports 256 colours) set t_Co=256
-
Bash提示:
/etc/bash.bashrc
下行添加到~/.bashrc
或/etc/bash.bashrc
:if [ -f ~/.local/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh ]; then source ~/.local/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh fi
-
Zsh提示:
/etc/zsh/zshrc
添加到~/.zshrc
/etc/zsh/zshrc
或/etc/zsh/zshrc
:if [[ -r ~/.local/lib/python2.7/site-packages/powerline/bindings/zsh/powerline.zsh ]]; then source ~/.local/lib/python2.7/site-packages/powerline/bindings/zsh/powerline.zsh fi
-
Tmux状态线:
~/.tmux.conf
添加到~/.tmux.conf
:source ~/.local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf set-option -g default-terminal "screen-256color"
如果您的终端支持256种颜色,请通过修改
~/.bashrc
或/etc/bash.bashrc
并添加以下行将TERM
环境变量设置为xterm-256color
:export TERM=xterm-256color
要检查您的终端是否支持256色,请检查终端的文档或谷歌。 最受欢迎的终端支持256种颜色。
用法:(用于全系统安装)
-
Vim状态栏:
在~/.vimrc
或/etc/vim/vimrc
添加以下内容:set rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/ " Always show statusline set laststatus=2 " Use 256 colours (Use this setting only if your terminal supports 256 colours) set t_Co=256
-
Bash提示:
/etc/bash.bashrc
下行添加到~/.bashrc
或/etc/bash.bashrc
:if [ -f /usr/local/lib/python2.7/dist-packages/powerline/bindings/bash/powerline.sh ]; then source /usr/local/lib/python2.7/dist-packages/powerline/bindings/bash/powerline.sh fi
-
Zsh提示:
/etc/zsh/zshrc
添加到~/.zshrc
/etc/zsh/zshrc
或/etc/zsh/zshrc
:if [[ -r /usr/local/lib/python2.7/dist-packages/powerline/bindings/zsh/powerline.zsh ]]; then source /usr/local/lib/python2.7/dist-packages/powerline/bindings/zsh/powerline.zsh fi
-
Tmux状态线:
~/.tmux.conf
添加到~/.tmux.conf
:source /usr/local/lib/python2.7/dist-packages/powerline/bindings/tmux/powerline.conf set-option -g default-terminal "screen-256color"
如果您的终端支持256种颜色,请通过修改
~/.bashrc
或/etc/bash.bashrc
并添加以下行将TERM
环境变量设置为xterm-256color
:export TERM=xterm-256color
要检查您的终端是否支持256色,请检查终端的文档或谷歌。 最受欢迎的终端支持256种颜色。
组态:
有关配置Powerline
: 配置的详细信息。
卸载:
要卸载Powerline
,请在终端中运行以下命令之一:
-
要卸载每个用户安装:
pip uninstall powerline
-
要卸载系统范围的安装:
su -c 'pip uninstall powerline'
来源: Powerline beta文档
备择方案:
如果你只是为Vim安装Powerline,你应该尝试更加可定制和轻量级的vim-airline 。
从Ubuntu 14.10(utopic)开始, Universe存储库中提供了powerline
包。 要安装它,只需在终端中运行此命令:
sudo apt-get install powerline
或者,您应该可以使用Ubuntu软件中心进行安装。
尽管已经回答了这个问题,但就目前Bash的安装而言,解决方案似乎也有点过分。 如果Powerline在早期的回购中可用,我不知道,但它在当前的回购中可用。 话虽如此,现在对Bash的抽象要少得多。
使用此命令安装Powerline;
sudo apt install powerline
对于每个用户配置,使用您选择的文本编辑器编辑.bashrc
。
gedit ~/.bashrc
并将其附加到文档中;
if [ -f `which powerline-daemon` ]; then powerline-daemon -q POWERLINE_BASH_CONTINUATION=1 POWERLINE_BASH_SELECT=1 . /usr/share/powerline/bindings/bash/powerline.sh fi
对于系统配置,请使用您选择的文本编辑器以root身份编辑/etc/bash.bashrc
。
sudo su
后跟gedit /bash.bashrc
并将其附加到文件中;
if [ -f `which powerline-daemon` ]; then powerline-daemon -q POWERLINE_BASH_CONTINUATION=1 POWERLINE_BASH_SELECT=1 . /usr/share/powerline/bindings/bash/powerline.sh fi
14.04使用最新版本的Powerline
随着最新安装的电力线,事情变得更加容易。 这是我如何去做的。
- 安装Vundle并在.vimrc中进行设置
- 通过Vundle软件包安装程序安装powerline
- 安装字体 (只需运行./install.sh脚本)。
-
在.vimrc中使用以下设置:
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'} " Powerline setup set laststatus=2 set term=xterm-256color set termencoding=utf-8 set guifont=Ubuntu\ Mono\ derivative\ Powerline:10 " set guifont=Ubuntu\ Mono let g:Powerline_symbols = 'fancy'
- 进入你的
~/.vim/bundles/powerline/fonts
文件夹,然后双击那里的字体。 安装它。 - (在某些系统上,您需要将powerline字体配置复制到
/etc/fonts/conf.d
) - 退出并重新登录。
注意:您不再需要通过pip安装它。
如果你只是想要bash扩展,我写了一个小脚本,自动化了Basharat Sialvi编写的手动步骤(非常感谢完整的参考)。
在综合中(但请先看看脚本,因为如果它将您的计算机抛出窗口或删除文件,我将不负责任):
git clone git@github.com:vincepii/ubuntu-powerline-bash.git cd ubuntu-powerline-bash ./install.sh
https://thealarmclocksixam.wordpress.com/2016/02/28/quickly-setup-powerline-for-bash-in-ubuntu/