I don't see anything obivously wrong with yours unless the linefeed is not just in your email. Does this one work without color?:
PS1='\...@\h:\w$(__git_ps1 " (%s)")$ ' if that works, try putting in things like \[\e[0;33m\] to switch to a new color. If that one doesn't work correctly without color, then I would guess that something is wrong with __git_ps1. But I am not an expert at this. Ryan On Tue, Jun 23, 2009 at 3:01 PM, asmeurer <[email protected]> wrote: > > OK I fixed that. I had too many $'s. The problem now is that it > doesn't change when I switch a branch or after cd'ing into and out of > a git directory. Ondrej's PS1 changes (though I get > aaronmeu...@macintosh:~/Documents/python/sympy/sympy33[31m(odes| > BISECTING)33[00m$ for my prompt on Mac OS X), but I cannot figure out > what is different in it. This is kind of useless unless it changes. > > Here is what I have: export PS1="\[\e[31;40m\]\h:\W \u\[\e[0m\]\[\e > [0;33m\]$(__git_ps1 "(%s)")\[\e[31;40m\]\$\[\e[0m\]" > > Aaron Meurer > On Jun 23, 1:32 pm, "Aaron S. Meurer" <[email protected]> wrote: > > I came up with this: export PS1="\[\e[31;40m\]\h:\W \u\$\[\e[0m\]\ > > [\e[0;33m\]$(__git_ps1 "(%s)")\[\e[31;40m\]$\[\e[0m\]" . It works, > > only I get > > > > Macintosh:~ aaronmeurer$$ > > > > when I am not in a git directory. Do you know if it possible to get > > rid of the extra $ when I am not in a git directory. Also, is there > > any way to get a different color if I am in a rebase (does PS1 have an > > if-else construct, or does can it auto update from something?)? > > > > Thanks for the link too. Autocompletetion in git is awesome. > > > > By the way, I think the \[\e[0m\] in my PS1 puts it back to the > > default color. > > > > Aaron Meurer > > On Jun 23, 2009, at 11:21 AM, Ondrej Certik wrote: > > > > > > > > > > > > > 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. > .. > > > > > 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 -~----------~----~----~----~------~----~------~--~---
