0

I'm using ubuntu 16.04, and I'm trying to get my terminal to show the current git branch, that I'm on, without much success.

First, I went into my .bashrc file

$ nano ~/.bashrc

then I posted in this code

parse_git_branch() {
 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

after I restarted the console, I still don't see the current branch. What is wrong?

0

How about this:

git branch | grep "^*"

Example:

$ git branch
  k410
  k411
  k412
  k413
  k416
  k416idle
  k416poll
  k416rc7-poll
  k418
  k418-jrw
  k418-rjw2
  k418-ufw2
  k418rc1test
* k419-rjw
  k45
  k46
  master
  ufw-test

And now:

$ git branch | grep "^*"
* k419-rjw

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.