Jakiś czas temu przedstawiałem w jaki sposób dostosować sobie bash prompt - dzisiaj przedstawiam bardziej rozbudowaną wersję pokazującą nazwę gałęzi w GIT.

git_color () {
   if git rev-parse --git-dir > /dev/null 2>&1; then
     if ! git status | grep "nothing to commit" > /dev/null 2>&1; then
       echo -e "\033[0;31m"
       return 0
     fi
   fi
   echo -e "\033[0;37m"
 }
 battery_status () {
   status=pmset -g batt | grep InternalBattery | awk '{ print $3 }' | awk -F\; '{print $1}'
   echo $status
 }
 disk_status () {
   status=df -h | grep /dev/disk1s1 | grep -v com.apple.TimeMachine | awk  '{ print $4}'
   echo $status
 }
 git_branch() {
   git branch 2> /dev/null | sed -e '/^[^]/d' -e 's/ (.*)/(\1) /'
 }
 DISK_COLOUR="\033[1;36m"
 BATTERY_COLOUR="\033[1;33m"
 DIR_COLOUR="\033[1;32m"
 RESET_COLOUR="\033[0m"
 BRANCH_COLOUR="\033[1;35m"
 export PS1="[$BATTERY_COLOUR]\$(battery_status) [$DISK_COLOUR]\$(disk_status)[$RESET_COLOUR] [$DIR_COLOUR]\W[$RESET_COLOUR] [$BRANCH_COLOUR]\$(git_branch)[$RESET_COLOUR][\$(git_color)]•[$RESET_COLOUR] "

Bash prompt po modyfikacji w pliku ~/.bashrc