[Insight-developers] Bash shell prompt customization

Arnaud GELAS arnaud_gelas at hms.harvard.edu
Mon Sep 27 15:47:00 EDT 2010


  Is bash-completion installed?

# yum install bash-completion

On 09/27/2010 03:48 PM, Bill Lorensen wrote:
> Sorry, but they don't work for me. I'm running Fedora 13.
>
> On Mon, Sep 27, 2010 at 3: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



More information about the Insight-developers mailing list