[Insight-developers] Bash shell prompt customization

Daniel Blezek Blezek.Daniel at mayo.edu
Mon Sep 27 15:42:48 EDT 2010


Anyone know where:

/usr/share/bash-completion/git

lives on the Mac?



On 9/27/10 2:38 PM, "Matthew McCormick (thewtex)" <matt at mmmccormick.com>
wrote:

>> 
>> I'm sure the experts already know this, but if you are using the bash
>> shell, you can customize the prompt to show which git branch is
>> active.
>> 
>> Here is what I added to my ~/.bashrc file:
>> 
>> parse_git_branch()
>>   {
>>   git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
>>   }
>> export 
>> PS1="[\[\e[01;34m\]\W\[\e[31m\]\$(parse_git_branch)\[\e[00m\]]\[\e[00m\]
>> "
>> 
> 
> Hi Bill,
> 
> This is a great tip.
> 
> Note that git already comes with some machinery to do this.  Here is what the
> relevant lines looks like in my .bashrc
> source /usr/share/bash-completion/git
> export PS1='\[\033[01;32m\]\u\[\033[00;34m\]@\[\033[01;35m\]\h\[\033[01;36m\]
> \w$(__git_ps1 " (%s)")\[\033[00;34m\]\$\[\033[00m\] '
> 
> There are tips in the comments of /usr/share/bash-completion/git for using
> __git_ps1.  There are a couple of customization available.
> 
> Matt
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers

-- 
Daniel Blezek, PhD
Medical Imaging Informatics Innovation Center

P 127 or (77) 8 8886
T 507 538 8886
E blezek.daniel at mayo.edu

Mayo Clinic
200 First St. S.W.
Harwick SL-44
Rochester, MN 55905
mayoclinic.org
"It is more complicated than you think." -- RFC 1925

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20100927/ff5502fc/attachment.htm>


More information about the Insight-developers mailing list