Reputation: 401
How to add branch name into console line like it made in Windows Bash
foo@bar MINGW64 /d/_GitRepo/game (master)
$
and change color theme
Upvotes: 2
Views: 1463
Reputation: 8601
If you just want to show the current branch in the terminal command line, this site could help you https://techcommons.stanford.edu/topics/git/show-git-branch-bash-prompt
To summarize:
Put this function in your .bashrc
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
It extracts the current branch.
Then edit value of the PS1 variable and call the function you created with $(parse_git_branch)
. It should look similar to this:
PS1="\h:\W \u$BLUE\$(parse_git_branch) $DEFAULT\$"
Upvotes: 1