How can we show branch name anytime we’re running terminal on git directory (Linux). It make your steps easier without always typing git branch anytime you’d like to know on what branch you are in.
1. Open ~/.bashrc
Open your ~/.bashrc on your favourite text editor.
2. Paste Configuration Code
Next you need to paste this code at the of the ~/.bashrc file:
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}export PS1="\e[1m\e[32m\u@\h\e[0m\e[0m:\e[1m\e[34m\w\e[0m\e[1;33m\$(git_branch)\e[0m\$ "
3. Custom Color
If you would like to use another color, you can go to this link to learn more: https://www.shellhacks.com/bash-colors/
4. Apply Configuration
Apply your configuration without you having to logout/login by execute this command:
$ source ~/.bashrc
— FINISHED —