PPaste!

Server Bash

Home - All the pastes - Authored by Thooms

Raw version

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Customize BASH PS1 prompt to show current GIT repository and branch.
# Though this file has been made for ATILLA servers, some of its contents are inspired from
# Mike Stewart's website : http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt

Reset="\033[0m"
Green="\033[0;32m"
BIRed="\033[1;91m"

function BranchIndicator
{
  # Check if the current folder has a git repository
  git branch &>/dev/null
  if [ "$?" -eq 0 ]; then
    # Check the repo status
    echo `git status` | grep "nothing to commit" > /dev/null 2>&1
    if [ "$?" -eq 0 ]; then
      echo -e $Green$(__git_ps1 " (%s)")$Reset" ";
    else
      echo -e $BIRed$(__git_ps1 " (%s)")$Reset" ";
    fi
  else
    echo " "
  fi
}

export PS1='\[\033[01;33m\]\H \[\033[01;34m\]\w\[\033[00m\]$(BranchIndicator)\[\033[01;33m\]\$\[\033[00m\] '