diff --git a/README.md b/README.md index 14acf20..e15296d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bash-powerline.sh b/bash-powerline.sh index 6b11e3f..ea4fd72 100644 --- a/bash-powerline.sh +++ b/bash-powerline.sh @@ -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 @@ -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"