188

Powerline is a plug-in to display informational and beautiful statusline for vim, tmux and shell prompt for bash, zsh.

Vim statusline: enter image description here enter image description here enter image description here enter image description here How can I install and setup Powerline for different applications and shells in Ubuntu?

landroni
  • 5,941
  • 7
  • 36
  • 58
Basharat Sialvi
  • 24,046
  • 8
  • 62
  • 82
  • 2
    Just as a note. My plugin was installed to dist-packages instead of site-packages so I had to point the applications to that directory instead. It seems to be a convention for debian-based distributions to be able to have more than one python installation configured. Anyways it took me a while to figure this out so I hope this can save you guys some headaches. – Eduardo M - bbaaxx Oct 03 '13 at 06:38
  • For your info: I have added a new, easier install method on 14.04. – don.joey Mar 13 '15 at 09:48

5 Answers5

247

Plugin Installation:

Install python-pip and git: Open terminal by hitting Ctrl+Alt+T and run:

sudo apt-get install python-pip git
  • Per user:
    In terminal run:

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

    Add ~/.local/bin to $PATH by modifying ~/.profile with your favourite editor:

    gksudo gedit ~/.profile
    

    and adding following lines at the end of it:

    if [ -d "$HOME/.local/bin" ]; then
        PATH="$HOME/.local/bin:$PATH"
    fi
    
  • System wide:
    In terminal run:

    su -c 'pip install git+git://github.com/Lokaltog/powerline'
    

Font Installation:

Powerline provides two ways of installing the required fonts. If you're using one of following terminal: Gnome Terminal, Konsole, lxterminal, st, Xfce Terminal, Terminator, Guake, Yakuake then you should use "Fontconfig" method.

  • Fontconfig: (recommended)

    • Per User:
      Run the following commands in terminal:

      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/
      
    • System wide:
      Run the following commands in terminal:

      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/
      
  • Patched font:
    Use this method only if "Fontconfig" method doesn't work for you or you're using a terminal other than mentioned above.

    1. Download the font of your choice from powerline-fonts.
    2. Move your patched font to ~/.fonts/ for per user installation or /usr/share/fonts for system wide installation.
    3. Run fc-cache -vf ~/.fonts to update your font cache, sudo fc-cache -vf to do it system wide.

To use patched font in Gvim see this answer and to change the font of your respective terminal check this question: How to change the font of various terminal emulators?. You may have to reboot your system after font installation for changes to take effect.

Usage: (for per user installation)

  • Vim statusline:
    Add following to your ~/.vimrc or /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 prompt:
    Add the following line to your ~/.bashrc or /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 prompt:
    Add the following line to your ~/.zshrc or /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 statusline:
    Add the following line to your ~/.tmux.conf:

    source ~/.local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf
    set-option -g default-terminal "screen-256color"
    

    If your terminal supports 256 colours, set TERM environment variable to xterm-256color by modifying ~/.bashrc or /etc/bash.bashrc and adding following line:

    export TERM=xterm-256color
    

    To check if your terminal supports 256 colours check the documentation of your terminal or google it. Most popular terminals support 256 colours.

Usage: (for system wide installation)

  • Vim statusline:
    Add following to your ~/.vimrc or /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 prompt:
    Add the following line to your ~/.bashrc or /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 prompt:
    Add the following line to your ~/.zshrc or /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 statusline:
    Add the following line to your ~/.tmux.conf:

    source /usr/local/lib/python2.7/dist-packages/powerline/bindings/tmux/powerline.conf
    set-option -g default-terminal "screen-256color"
    

    If your terminal supports 256 colours, Set TERM environment variable to xterm-256color by modifying ~/.bashrc or /etc/bash.bashrc and adding following line:

    export TERM=xterm-256color
    

    To check if your terminal supports 256 colours check the documentation of your terminal or google it. Most popular terminals support 256 colours.

Configuration:

For detailed information on configuring Powerline: Configuration.

Uninstall:

To uninstall Powerline run one of following commands in terminal:

  • To uninstall per user installation:

    pip uninstall powerline
    
  • To uninstall system wide installation:

    su -c 'pip uninstall powerline'
    

Source: Powerline beta documentation

Alternatives:

If you're installing Powerline just for Vim you should try vim-airline which is more customizable and lightweight.

Basharat Sialvi
  • 24,046
  • 8
  • 62
  • 82
  • 1
    It should probably also be mentioned that the user will need to set their emulator to "login" so that ~/.profile will be properly ran or they might run into issues with not being able to use their terminal when it's unable to find the powerline command. – Jordon Bedwell May 25 '13 at 02:36
  • 1
    as pointed below, the installation path for system wide is /usr/local/lib/python2.7/dist-packages/powerline/. So at the vimrc you should point at /usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/ instead – dinigo Nov 14 '13 at 17:31
  • 1
    @demil133 Fixed! – Basharat Sialvi Nov 14 '13 at 18:20
  • Basharat Sial's answer is very good; however, when trying to have vim point to the package in the python library for the system wide install, the path that worked for me was: /usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/ Basically just replace the site-packages with dist-packages wherever it appears for the "Usage" steps. Hope this helps anyone who runs into the same thing. – alphurdex Nov 04 '13 at 00:53
  • 1
    for me (on Ubuntu 12.04) per user font installation doesn't work I had to install fonts system wide – jmarceli Dec 07 '13 at 08:38
  • Finally setting this in .bashrc helped LANG=en_US.utf8. – RajaRaviVarma Mar 03 '14 at 18:46
  • 3
    No longer works in Ubuntu 15.04 – Goddard Jul 16 '15 at 22:54
  • Shouldn't Vim be compiled with Python support? – Alan Kis Apr 14 '16 at 19:46
  • I have followed your solution line by line. But I am not getting the arrow symbols in my bash terminal. But I was able to get them inside Vim. Please help, thanks. – TheLinuxEvangelist Oct 28 '16 at 11:02
  • Never mind, i found a solution: I added the following line:

    export LC_CTYPE="en_US.UTF-8"

    to my .bashrc . Earlier it was "en_IN"

    – TheLinuxEvangelist Oct 28 '16 at 12:03
  • Could you add the instructions for installing on the "Windows Linux Subsystem" ? – Oneezy Jan 03 '17 at 09:15
  • @TheLinuxEvangelist I still don't get arrow symbols on prompt after adding that line. –  Mar 19 '17 at 08:44
  • Please update the answer with latest changes. – Anwar Mar 19 '17 at 15:45
  • @vikramreddym Follow all the steps in the answer and change the LC_TYPE it might be en_IN because of your region settings – TheLinuxEvangelist Mar 20 '17 at 16:36
  • @TheLinuxEvangelist, cc: @Anwar, Finally it worked but not with what you suggested. First I ran locale to check the language and all the variables had en_IN. So I had to run sudo locale-gen en_US en_US.UTF-8 and then I ran sudo dpkg-reconfigure locales. In the configuration menu, I have deselected en_IN using spacebar when it asked me to select which ones to regenerate and selected en_US-UTF-8 in the next menu. So thanks for pointing me in the right direction. –  Mar 20 '17 at 21:47
  • Adding below line to .bashrc file works for me if [ -d "$HOME/.local/bin" ]; then PATH="$HOME/.local/bin:$PATH" fi export POWERLINE_COMMAND=powerline

    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

    – Naresh Joshi May 09 '17 at 06:53
  • For vim it works. But for bash I get the following error: bash: /home/wolfgang/.local/lib/python2.7/site-packages/powerline/bindings/bash/../../../scripts/powerline-config: No such file or directory – LRDPRDX Mar 20 '18 at 11:36
  • Works on WSL (Ubuntu 18.04). This is the best explanation on internet for powerline installation and setup. Even better than the official docs :-D – codeartist Mar 24 '19 at 02:23
  • 1
    in 19.04, powerline now uses Python 3 and the path has changed to (/usr/share/powerline/bindings/bash/powerline.sh) – Scott P. May 09 '19 at 15:18
36

As of Ubuntu 14.10 (utopic), a powerline package is available in the universe repository. To install it, just run this command in your terminal :

sudo apt-get install powerline

Alternatively, you should be able to install it by using the Ubuntu Software Center.

jcharaoui
  • 469
  • 3
    This doesn't really solve my problem though. Is there anything else on top of this that needs to be performed for this to work? – Michael Aquilina Feb 13 '15 at 15:41
  • 8
    Yes, there is, but it depends on how you want to use powerline. Instructions on how to integrate it in common applications are found in the package documentation located in /usr/share/doc/powerline. The relevant file in this package is README.Debian. – jcharaoui Feb 17 '15 at 21:21
  • If instruction is found in the doc, put them here. Otherwise it doesn't worth just writing the command to install it because installing doesn't do anything – Anwar Nov 27 '16 at 18:02
  • It should be added that this method does not include bash bindings and many other bindings are missing. – Goddard Aug 19 '17 at 21:18
  • 2
    All bindings are included in the powerline package, including bash bindings. They are installed in /usr/share/powerline/bindings. – jcharaoui Apr 13 '18 at 01:25
  • Solved it for me after installing the font system wide. – Daniel Andrei Mincă Nov 26 '18 at 13:37
28

Though this has been answered, it seems the solution may also be somewhat overkill in terms of the installment for Bash at this point in time. Unaware am I if Powerline was available in the earlier repos, but it is available in the current repos. That being said, it's much less abstracted for Bash right now.

Install Powerline using this command;

sudo apt install powerline

For per user configuration, edit your .bashrc with your text editor of choice.

gedit ~/.bashrc

And append this to the document;

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

For system configuration, edit /etc/bash.bashrc as root with your text editor of choice.

sudo su followed by gedit /bash.bashrc

and append this to the document;

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
6

On 14.04 with the latest version of Powerline

With the latest install of powerline things have gotten a lot easier. Here is how I went about it.

  1. Install Vundle and set it up in your .vimrc
  2. Install powerline through the Vundle package installer
  3. Install the fonts (just run the ./install.sh script).
  4. Use the following settings in your .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'
    
  5. Go into your ~/.vim/bundles/powerline/fonts folder and double click the font that is in there. Install it.
  6. (On some systems you need to copy the powerline font config to /etc/fonts/conf.d)
  7. Log out and back in.

Note: you do not need to install it via pip anymore.

don.joey
  • 28,662
  • How does this method affect the availability of Powerline for use in shells, tmux, etc.? – Dennis Williamson Jun 05 '15 at 03:06
  • @DennisWilliamson To be honest, I would not know as I have not used powerline in those contexts. Because all the configuration is vim specific, I could imagine that this does not affect the other contexts at all. – don.joey Jun 05 '15 at 07:23
  • @don.joey According to the documentation, they should not be used side by side (see the warning box): https://powerline.readthedocs.org/en/latest/usage/other.html#vim-statusline – Andrew Jul 02 '15 at 06:10
  • @Andrew I am not sure I get your point. You mean you should not install both via Vundle and via pip? Because that is not what I am suggesting, right? – don.joey Jul 02 '15 at 11:36
  • Yes, that's what I mean. Isn't that what you were suggesting? Vundle works for vim-only but if you want it in multiple places then instead install via pip only, then configure for vim. – Andrew Jul 02 '15 at 15:23
2

If you just want the bash extension, I wrote a small script that automates the manual steps that Basharat Sialvi wrote (many thanks for that complete reference).

In synthesis (but please, have a look at the script first as I won't be responsible if it throws your computer out of the window or delete your files):

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/

https://github.com/vincepii/ubuntu-powerline-bash

Vincenzo Pii
  • 1,839