Add it to PS1
using Mac :
PS1='\W@\u >`[ -d .git ] && git branch | grep ^*|cut -d"" -f2`> $ '
Before running the command above :
![enter image description here]()
After running that command :
![enter image description here]()
Dont worry, if it is not GIT repository , it will not display error because of [-d .git]
which checks if .git
folder exists or not.