Git branch name in your prompt

When you want to get something similar like
idea:~/my/project/hybris/order-service (develop) 
as your Bash prompt on a Mac or perhaps some other Unix OSs — where "(develop)" could be your currently checked out Git branch — add this
PS1='\h:\[\e[0;31m\]\w\[\e[m\]`__git_ps1` ' 
or 
PS1='\h:\[\e[0;31m\]\w\[\e[m\] \e[1;31m\]$(__git_ps1 %s)\e[m ' 
to your ~/.bash_profile

Alternatively you could use
PS1='`__git_ps1` '
just to see the branch name.

Comments

Popular posts from this blog

Tuning ext4 for performance with emphasis on SSD usage

Rust’s impact on the industry

Brandan Eich on WebAssembly, Web Workers, and Decorators