[mythtv] [GIT tip] Git Bash Prompt

Jarod Wilson jarod at wilsonet.com
Fri Jan 21 15:03:04 UTC 2011


On Fri, Jan 21, 2011 at 5:38 AM, Colin Guthrie <mythtv at colin.guthr.ie> wrote:
> Hi,
>
> As some folks are still quite new to git, I thought I'd post this little
> tip, that I really love.

Been using the same (more or less) on Fedora and RHEL for some time
myself, and yeah, its insanely helpful when working with git repos.


> I packaged this up in Mandriva, so if you use that platform, just:
>  urpmi git-prompt
>
> (NB If other distro packages could provide a similar package that would
> be great as it's a useful convenience)

The main logic is part of the core git package in Fedora/RHEL, which
installs /etc/bash_completion.d/git. I'm not actually using full-blown
additional bash completion, so I'm sourcing that in via .bashrc, and
incorporating the necessary __git_ps1 into my already personally
customized PS1.

Full range of the relevant .bashrc bits I've added:

source /etc/bash_completion.d/git
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true

# color prompt
BLUE='\[\033[01;34m\]'
GREEN='\[\033[01;32m\]'
BLACK='\[\033[00m\]'
YELLOW='\[\033[01;33m\]'
RED='\[\033[01;31m\]'
PS1='['$GREEN'\u'$BLUE'@\h '$RED'\W'$YELLOW'$(__git_ps1 " (%s)")'$BLACK']\$ '
export PS1


-- 
Jarod Wilson
jarod at wilsonet.com


More information about the mythtv-dev mailing list