Yeah, adding the branch name in the command prompt might be an easy task in third-party Command Editors, but not so straightforward in default editors.
So, I did some research and found the snippet that helps us to place branch name, in the prompt.
Here are the steps:
So, I did some research and found the snippet that helps us to place branch name, in the prompt.
Here are the steps:
- Open .bash_profile of the user
- vi ~/.bash_profile
- Add the following code in the file
1 2 3 4 5 6
# Git branch in prompt. parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
- Save the file and exit the command prompt.
- Restart the command prompt and you will be having the branch.
Thanks
and
Happy Coding :)