diff options
Diffstat (limited to 'bashrc')
-rw-r--r-- | bashrc | 57 |
1 files changed, 57 insertions, 0 deletions
@@ -170,6 +170,63 @@ showdiff() { local feat=${1-HEAD} target=${2-origin/master} diffWith "git diff $target...$feat -w -D -M --patience --find-copies-harder" } +style_reset() { + echo -ne "\001\e[0m\002" +} +style_set() { + echo -ne "\001\e[${1};${2}m\002" +} +style_message() { + echo -ne " $(style_set $1 $2)$3$(style_reset)" +} +git_prompt() { + local branchname=$(git branch --show-current 2> /dev/null) + if [[ -n $branchname ]]; then + local detail=$(git branch --list $branchname -v 2> /dev/null) + local status=$(git status --porcelain 2> /dev/null) + local style=00 + local color=92 + if [[ $detail =~ ahead\ [0-9] ]]; then + if [[ $detail =~ behind\ [0-9] ]]; then + style=05 + else + style=03 + fi + elif [[ $detail =~ behind\ [0-9] ]]; then + style=04 + fi + if [[ -n $status ]]; then + color=96 + fi + style_message $style $color $branchname + fi +} +bjam_prompt() { + if [[ -f Jamfile.jam || -f Jamroot.jam ]]; then + local updates=$(bjam -nd1 | sed -n 's/^\.\.\.updated \([0-9]\+\) targets\.\.\.$/\1/p') + if [[ -n $updates ]]; then + style_message 01 31 $updates + fi + fi +} +result_prompt() { + case $1 in + 0) + style_message 00 32 ✔ + ;; + "") + style_message 01 34 $ + ;; + *) + style_message 01 91 ✘ + ;; + esac +} +prompts() { + local res=$? + git_prompt + result_prompt $res +} gppdmb() { PARENT=${1:-master} git checkout $PARENT && git pull --prune && git delete-merged-branches |