#!/bin/bash set -o pipefail [[ "$TERM" = *color ]] && mitFarbe=true || mitFarbe=false [ -z "$PS1Start" ] && [ -z "$PS1Ende" ] && if echo "$PS1" | grep -q "\S" then PS1Ende="$(echo "$PS1" | sed "s|^.*[^\\]\(\\\\\?\S\s*\)\$|\1|")" PS1Start="$(echo "$PS1" | sed "s|\\\\\?\S\s*\$||")" else PS1Ende="" PS1Start="$PS1" fi PS1="$PS1Start" if branch=$(git branch 2>/dev/null | grep '^\*' | sed "s|^\*\s*||") then PS1="$PS1 " status=$(git status --porcelain) echo "$status" | grep -q "^.\S" && wtClean=false || wtClean=true echo "$status" | grep -q "^\S" && idxClean=false || idxClean=true if $mitFarbe then if ! $wtClean then PS1="$PS1\[\033[01;31m\]" elif ! $idxClean then PS1="$PS1\[\033[01;33m\]" else PS1="$PS1\[\033[01;32m\]" fi fi PS1="$PS1$branch" if $mitFarbe then PS1="$PS1\[\033[00m\]" else if ! $wtClean then PS1="$PS1!" elif ! $idxClean then PS1="$PS1+" fi fi fi PS1="$PS1$PS1Ende"