#202 ✓invalid

showing git branch in path for linux

Reported by luckysmack | May 19th, 2010 @ 06:52 AM

on the following page:


you mention that the terminal path shows the branch in the path in windows, and yes that is windows only. But to add this ability in linux you can edit your ~/.bashrc file with the following:

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

export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\] $(parse_git_branch)$ '

the parse_git_branch function will pull the current projects branch name. the export line will add the branch name to the end of the path. For example, my path looks like so:

shamce /var/www/sites/shamce.net/shamce (dev) $
^computer name
shamce /var/www/sites/shamce.net/shamce (dev) $
-------^ path
shamce /var/www/sites/shamce.net/shamce (dev) $
-----------------------------------------^ branch

the export line will also colorize the path to make it more readable.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Please use this for the current version of Infinitas only, if you are using a older version of the Infinitas report bugs in that project.

Please submit bugs only as pending, and if its a feature request submit the ticket with the milestone "Feature Requests".

Shared Ticket Bins

People watching this ticket