rikimaru2013
rikimaru2013

Reputation: 401

Git bash on Ubuntu

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

Answers (1)

NaN
NaN

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

Related Questions