[Yanel-dev] showing git branch in command prompt

Michael Wechner michael.wechner at wyona.com
Wed Oct 19 14:15:19 CEST 2011


Btw, I just tested "restart" on Mac OS X and it works very fine (whereas 
to be safe I had created another "sudo" account).

@Simon: I guess you are using Ubuntu, right?

The code below should not be specific for Mac OS X. Any pointers to 
clarify are much appreciated.

Thanks

Michael

Am 19.10.11 13:55, schrieb Michael Wechner:
> Hi Simon
>
> Sorry to hear that you had trouble with the "git console code", but I 
> think it would be good to figure out
> what the real problem is that this code seems to cause.
>
> Can you post the hints of th" xorg errors"?
>
> Thanks
>
> Michael
>
> Am 19.10.11 12:17, schrieb simon:
>> hi all
>>
>> after adding this lines to my .profile everything looked good. but 
>> when i restarted my computer i could not login anymore. it just throw 
>> me back to the login screen. after searching a solution for this 
>> problem for a long long time i gave up and installed the system new. 
>> everything worked fine. after a while i had the same problem again. 
>> finally i found a hint in the xorg errors which pointed to the lines 
>> of this script. after removing it i could login again.
>>
>> so this f*** lines cost me really a lot of time and nerves.
>>
>> hope this helps others to avoid such problems.
>>
>> cheers
>> simon
>>
>> Am 30.09.2011 14:28, schrieb Michael Wechner:
>>> Hi
>>>
>>> A friend of mine pointed out me how to show the git branch in the 
>>> command prompt:
>>>
>>> https://duckduckgo.com/?q=show+git+branch+command+prompt
>>>
>>> whereas I am currently doing it as follows on a Mac. Add the 
>>> following lines to /Users/MY_NAME/.profile
>>>
>>> function parse_git_branch () {
>>>        git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ 
>>> (\1)/'
>>> }
>>>
>>> RED="\[\033[0;31m\]"
>>> YELLOW="\[\033[0;33m\]"
>>> GREEN="\[\033[0;32m\]"
>>> NO_COLOUR="\[\033[0m\]"
>>>
>>> PS1="$GREEN\u at macbook$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ 
>>> "
>>>
>>> and start a new terminal window and then you should see something like:
>>>
>>> michaelwechner at macbook:~/src/yanel (master)$
>>>
>>> which is more convenient than typing "git branch" ;-)
>>>
>>> HTH
>>>
>>> Michael
>>>
>>
>



More information about the Yanel-development mailing list