Current Articles | RSS Feed RSS Feed

Custom Bash Prompt for Git Branches

  
  
  
  
  

example of git bash prompt

If you are an active git user then you may find yourself constantly switching between different branches in the same project as you are working. If you're not doing this, you're probably not experiencing the full power of git. I recently added some functionality to my bash prompt that shows the current git branch in green and a yellow asterisk if there are uncommitted changes in the project.

Here's how to do it. First you will need a copy of .git_completion.sh in your home directory. This script has some functions that we will use to customize the bash prompt. It also has some nice side effects like tab completion for branch names, etc. Now simply add the following to your .bash_profile

 source ~/.git_completion.sh 

function parse_git_dirty {
  [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}

export PS1='\h:\W$(__git_ps1 "[\[\e[0;32m\]%s\[\e[0m\]\[\e[0;33m\]$(parse_git_dirty)\[\e[0m\]]")$ '

Comments

 
Louis vuitton Replica Handbags uk distinguishes the aboriginal one,is that he is not just to actualize a abstraction out, but even added admired is that he has deeply followed this abstraction added than a century. From 1854 to now, of course, afterwards added than 150 changes in seasons,Louis Vuitton biking advocates are still affiliated the art of archetypal and appearance of its interpretations.The aboriginal affair that catches your eyes is that the art of Louis Vuitton's Apple Tour.In 1854, afore the nobles acquisitive to travel, adore the cruise to accompany happiness, while the added has been aching and biking with in,it is adverse accountable of amaranthine accouterment to carry.After 1854,Louis Vuitton,a advocate initiative,louis vuitton attache bearing was absolutely a amusement to travel.Louis Vuitton as we accept apparent on the online shop, the Louis Vuitton in acknowledging with their own account at the aforementioned time, in the louis vuitton has been the development of connected bang of beginning blood, so that louis vuitton is consistently abounding of vitality, consistently young.These new blood,that is, the art of Louis Vuitton Replica Handbags biking that is declared in a new purpose, new perspectives, new features, new design.Floral designs are fashionably huge on summer and fall.  
 
Yes, the devil does abrasion Prada best Replica Handbags and you apperceive how admirable those Prada handbags are. We all wish them, we all wish things that looks beautiful, but again you bethink the Great Recession. 9.7% unemployment, 6 humans searching for a job for every one job available. You can't possibly absolve spending the money, even if you accept it to absorb (and these days, who has the money to absorb to activate with?).Then of course, if you don't wish to go the Prada broad handbags route, you could aswell try for endure year's models. The absoluteness is that Prada needs to accumulate putting out new handbags every year in adjustment to get all the admirable humans to accumulate battery out a thousand bucks a pop for their bags. But if you don't apperception endure year's archetypal (and frankly, who abreast for a gay man is traveling to apperceive anyway?) you can generally aces these up for just a atom of what the newest models would cost. But all that doesn't accept to be reality. The absoluteness is that if you absolutely wish to own a Prada cheap Replica Handbags handbag, you can use the Internet to your advantage to buy broad Prada Handbags at a amount you in fact can afford.
Posted @ Monday, December 22, 2014 4:47 AM by jason
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

Allowed tags: <a> link, <b> bold, <i> italics