Hi Ryan,

On Tue, Jun 23, 2009 at 8:10 AM, Ryan Krauss<[email protected]> wrote:
> After watching Ondrej's git videos, I became jealous of the (branch name) at
> the end of his bash prompt.  I googled around and was able to put something
> together that I like.  The trick was getting it to work in color.
> Especially tricky for me was getting back to the default white after the
> branch name.  I found that I could get either light gray or bold white,
> neither of which I liked.  But a code that doesn't really make sense to bash
> seems to get me back to the default.
>
> I added these to my .bashrc:
> function parse_git_branch() {
> git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
> }
> PS1="\...@\h:\w\[\e[0;33m\]\$(parse_git_branch)\[\e[0;39m\]$ "
>
> where \[\e[0;33m\] switches to a medium yellow and \[\e[0;39m\] switches
> back to the default white (for me).
>
> I borrowed ideas from these places:
>
> How to get the branch name in the prompt:
> http://eddorre.com/tags/bash
>
> how to tweak the other things in the prompt:
> http://www.linuxselfhelp.com/howtos/Bash-Prompt/Bash-Prompt-HOWTO-2.html
>
> and how to put things in color:
> http://wiki.archlinux.org/index.php/Color_Bash_Prompt
>
> Ondrej may have a cleaner solution, but I like it a lot.

Sorry that I forgot to say how to do it. The way you did is one way,
but it's too complex. I wrote how to do it here in a comment:

http://asmeurersympy.wordpress.com/2009/06/22/how-to-permanently-lose-data-with-git-and-then-retrieve-it-again/

Basically Aaron's post is that he lost some data, because he didn't
know he was doing a rebase. So I replied:


--------------
It’s because you don’t color your prompt with the name of the branch
(and the prompt also changes to something like “master|REBASE” if you
rebase). See here how it looks like:

http://code.google.com/p/sympy/wiki/GitTutorials

so I very, very strongly suggest you use that.

http://blog.ericgoodwin.com/2008/4/10/auto-completion-with-git

e.g. here is my PS1 prompt:

PS1=’${debian_chroot:+($debian_chroot)}...@\h:\w\[33[31m\]$(__git_ps1
“(%s)”)\[33[00m\]\$ ‘

if you use Mac, source the “contrib/completion/git-completion.bash”
file (in the git repository for git), which contains the definition of
the __git_ps1 and some documentation too (read it if you have troubles
getting it work).

Once you have the colored prompt, I am pretty sure it will never happen again.
-----------------


Ondrej

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to