Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ Powerline for Bash in pure Bash script.

Download the Bash script

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

And source it in your `.bashrc`

source ~/.bash-powerline.sh

You need a terminal capable of displaying at least 16 colors. By default, this is not the case in Ubuntu and Mint. Therefore add this to your `.bashrc`:

export TERM=xterm-256color

For best result, use [Solarized
colorscheme](https://github.com/altercation/solarized) for your terminal
emulator. Or hack your own colorscheme by modifying the script. It's really
Expand Down
7 changes: 3 additions & 4 deletions bash-powerline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ __powerline() {
[ -x "$(which git)" ] || return # git not found

# get current branch name or short SHA1 hash for detached head
local branch="$(git symbolic-ref --short HEAD 2>/dev/null || git describe --tags --always 2>/dev/null)"
local branch="$(git symbolic-ref HEAD 2>/dev/null | sed -e s#refs/heads/## || git describe --tags --always 2>/dev/null)"
[ -n "$branch" ] || return # git branch not found

local marks
Expand All @@ -78,9 +78,8 @@ __powerline() {
[ -n "$(git status --porcelain)" ] && marks+=" $GIT_BRANCH_CHANGED_SYMBOL"

# how many commits local branch is ahead/behind of remote?
local stat="$(git status --porcelain --branch | grep '^##' | grep -o '\[.\+\]$')"
local aheadN="$(echo $stat | grep -o 'ahead \d\+' | grep -o '\d\+')"
local behindN="$(echo $stat | grep -o 'behind \d\+' | grep -o '\d\+')"
local aheadN="$(LC_ALL=C git status | grep 'ahead' | grep -P -o '\d+')"
local behindN="$(LC_ALL=C git status | grep 'behind' | grep -P -o '\d+')"
[ -n "$aheadN" ] && marks+=" $GIT_NEED_PUSH_SYMBOL$aheadN"
[ -n "$behindN" ] && marks+=" $GIT_NEED_PULL_SYMBOL$behindN"

Expand Down