tag:blogger.com,1999:blog-7012742729372608936.post3574950895465366680..comments2022-01-30T13:23:22.603+01:00Comments on This is not a programmer's blog.: Hack of the day: displaying the repository location in your bash promptAnonymoushttp://www.blogger.com/profile/00034116782690900048noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7012742729372608936.post-14542160996324755042008-09-18T19:26:00.000+02:002008-09-18T19:26:00.000+02:00For extra points, colorize it as in p.89 of "Pract...For extra points, colorize it as in p.89 of "Practical Development Environments" (O'Reilly, 2005)<BR/><BR/>PS1="[\u@\h\$(\<BR/>if [ -d CVS ]; then \<BR/>if [ -e CVS/Tag ]; then \<BR/>cat CVS/Tag | sed -e 's/^T/ /' | sed -e 's/^N/ /' \<BR/>| sed -e 's/^D/ Date /' | sed -e 's/_branch/\[\033]12;blue\007\]/';<BR/>\<BR/>else \<BR/>echo ' \[\033]12;black\007\]MAIN' ; \<BR/>fi; \<BR/>else \<BR/>echo '\[\033]12;black\007\]' ; \<BR/>fi) \W]\\$ "Matt Doarhttps://www.blogger.com/profile/02360651363519410698noreply@blogger.comtag:blogger.com,1999:blog-7012742729372608936.post-40380693134138829672008-09-18T09:18:00.000+02:002008-09-18T09:18:00.000+02:00> GITLOC=$(git branch -a | grep -e '^*'...> GITLOC=$(git branch -a | grep -e '^*' | cut -d' ' -f2-)<BR/><BR/>Use sed instead:<BR/><BR/>git branch | sed -ne 's/\* \(.*\)/\1/p'<BR/><BR/>Or maybe this:<BR/><BR/>git symbolic-ref HEAD | sed 's#refs/heads/##'<BR/><BR/>You can use "git rev-parse" to check if you are in a git repo also.Anonymousnoreply@blogger.com