[Insight-developers] Bash shell prompt customization

Bill Lorensen bill.lorensen at gmail.com
Mon Sep 27 15:48:27 EDT 2010


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


More information about the Insight-developers mailing list