/bash-powerline

Powerline-style Bash prompt in pure Bash script

Primary LanguageShell

bash-powerline

Powerline for Bash in pure Bash script.

bash-powerline bash-powerline

Features

  • Git branch: display current git branch name, or short SHA1 hash when the head is detached
  • Git branch: display "+" symbol when current branch is changed but uncommited
  • Git branch: display "⇡" symbol and the difference in the number of commits when the current branch is ahead of remote (see screenshot)
  • Git branch: display "⇣" symbol and the difference in the number of commits when the current branch is behind of remote (see screenshot)
  • Platform-dependent prompt symbol for OS X and Linux (see screenshots)
  • Color code for the previously failed command
  • Fast execution (no noticable delay)
  • No need for patched fonts

Installation

Download the Bash script

curl https://raw.githubusercontent.com/riobard/bash-powerline/master/bash-powerline.sh > ~/.bash-powerline.sh

And source it in your .bashrc

source ~/.bash-powerline.sh

For best result, use Solarized colorscheme for your terminal emulator. Or hack your own colorscheme by modifying the script. It's really easy.

Why?

This script is largely inspired by powerline-shell. The biggest problem is that it is implemented in Python. Python scripts are much easier to write and maintain than Bash scripts, but for my simple cases I find Bash scripts to be manageable. However, invoking the Python interpreter each time to draw the shell prompt introduces a noticable delay. I hate delays. So I decided to port just the functionalities I need to pure Bash script instead.

The other issue is that I don't like the idea of requiring patched fonts for this to work. The font patching mechanism from the original Powerline does not work with the bitmap font (Apple Monaco without anti-aliasing) I use on non-retina screens. I'd rather stick with existing unicode symbols in the fonts.

See also

  • powerline: Unified Powerline written in Python. This is the future of all Powerline derivatives.
  • vim-powerline: Powerline in Vim writtien in pure Vimscript. Deprecated.
  • tmux-powerline: Powerline for Tmux written in Bash script. Deprecated.
  • powerline-shell: Powerline for Bash/Zsh/Fish implemented in Python. Might be merged into the unified Powerline.
  • emacs powerline: Powerline for Emacs