Git: display current branch name in the terminal

enter image description here
As simple as beautiful trick for me.
Add following lines to ~/.bashrc to allow your terminal to display the current branch name in the command line :

get_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

PS1="[\u@\h \W\[\033[31m\]\$(get_git_branch)\[\033[00m\]]$ "

Written with StackEdit.

Comments

Popular posts from this blog

Geminabox: Simple private RubyGems server on your own host

Gedit: make links clickable (with Ruby script)

Using Jenkins as HTTP server for your custom HTML