Get that nice Git branch displayed in your terminal

Add the following to get the active Git branch displayed in your terminal.

Get that nice Git branch displayed in your terminal

Add the following to get the active Git branch displayed in your terminal.

1
serveradmin@svr-docker-prod-01:~/homeops/infra/prod/pangolin/docker-compose (main)` 

For your bash terminal you’ll need to edit ~/.bashrc and add the following to the EoF.

1
2
3
4
5
6
7
# Function to show the current Git branch
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
    }

# Custom PS1 prompt with Git branch
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\$ "
Built with Hugo
Theme Stack designed by Jimmy