Powerline是一个插件,用于在vim、tmux和bash、zsh的命令提示符中显示信息和漂亮的状态栏。
Vim状态栏:
如何在Ubuntu上安装和设置Powerline以适用于不同的应用程序和shell?
Powerline是一个插件,用于在vim、tmux和bash、zsh的命令提示符中显示信息和漂亮的状态栏。
Vim状态栏:
如何在Ubuntu上安装和设置Powerline以适用于不同的应用程序和shell?
安装 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"方法对您无效或者您使用的终端不同于上述提到的终端时,才使用此方法。
~/.fonts/
(用户级别安装)或/usr/share/fonts
(系统级别安装)。fc-cache -vf ~/.fonts
以更新字体缓存,运行sudo fc-cache -vf
以进行系统级更新。Vim状态栏:
将以下内容添加到您的~/.vimrc
或/etc/vim/vimrc
文件中:
set rtp+=$HOME/.local/lib/python2.7/site-packages/powerline/bindings/vim/
" 始终显示状态栏
set laststatus=2
" 使用256种颜色(仅在终端支持256种颜色时使用此设置)
set t_Co=256
Bash提示符:
将以下行添加到您的~/.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提示符:
将以下行添加到您的~/.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
文件中:
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/
" 始终显示状态栏
set laststatus=2
" 使用256种颜色(仅在您的终端支持256种颜色时使用此设置)
set t_Co=256
Bash提示符:
将以下行添加到您的~/.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提示符:
将以下行添加到您的~/.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
文件中:
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,它更加自定义和轻量级。
site-packages
替换为dist-packages
。希望这对遇到相同问题的人有所帮助。 - alphurdex/usr/local/lib/python2.7/dist-packages/powerline/
。因此,在 vimrc 文件中,您应该指向 /usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/
。 - dinigoexport LC_CTYPE="en_US.UTF-8"
之前是"en_IN"。 - TheLinuxEvangelistlocale
命令来检查语言设置,所有变量都显示为en_IN
。所以我需要运行sudo locale-gen en_US en_US.UTF-8
,然后再运行sudo dpkg-reconfigure locales
。在配置菜单中,当它要求我选择要重新生成的语言时,我使用空格键取消选择了en_IN,并在下一个菜单中选择了en_US-UTF-8。所以感谢你指导我朝正确的方向前进。 - user616624bash
,我遇到了以下错误:bash: /home/wolfgang/.local/lib/python2.7/site-packages/powerline/bindings/bash/../../../scripts/powerline-config: 没有这个文件或目录。 - LRDPRDXpowerline
软件包。要安装它,只需在终端中运行以下命令:
sudo apt-get install powerline
或者,您也可以通过使用Ubuntu软件中心来安装它。/usr/share/doc/powerline
目录下的软件包文档中找到。该软件包中相关的文件是README.Debian。 - jcharaouipowerline
软件包中,包括bash绑定。它们被安装在/usr/share/powerline/bindings
目录下。 - jcharaouiif [ -f `which powerline-daemon` ]; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/share/powerline/bindings/bash/powerline.sh
fi
/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
安装了最新版本的Powerline后,事情变得更加容易了。以下是我的操作步骤。
在你的 .vimrc 文件中使用以下设置:
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
" Powerline 设置
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
文件夹,双击其中的字体并进行安装。/etc/fonts/conf.d
中)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/
export LC_CTYPE="en_US.UTF-8"
之前是"en_IN"。 - TheLinuxEvangelist