OT: Environment Status

1 view
Skip to first unread message

byrnejb

unread,
Aug 14, 2009, 10:50:09 AM8/14/09
to Cukes
Having to work on more than one git branch simultaneously sometimes
causes me to lose my place and opens up the possibility of making
alterations on the wrong branch. This risk seems greatest when
starting up again some time after after finishing a session.

I discussed this problem with a colleague and expressed the wish that
there was some way of automatically running a script whenever I
entered a working directory. Well, he came up with the following and,
as it has proven so helpful for me, I thought that others might find
it beneficial as well.

When I cd to a rails project now this is what I see:

[byrnejb@inet04 ~]$ cd projects/proforma.git
Rails Environment is: development
Git branch is:
Deploy-V.01.01.01
Deploy-V.01.01.03
* authorisation
master
[byrnejb@inet04 proforma.git]$

To obtain this ability then in your ~/.bashrc add this function:

cd()
{
command cd $1 || exit
if [ -x ./.pwdstatus ]
then
./.pwdstatus
fi
}

Then, in any directory that you wish to remind yourself of something
create a file called .pwdstatus, or whatever name you put into the
function. In that file add whatever commands you desire to have run
when you enter that directory. In my case I use this:

$ cat .pwdstatus
export
CUCUMBER_COLORS="passed=white,bold:passed_param=white,bold,underline"
export RAILS_ENV='development'
echo "Rails Environment is: "$RAILS_ENV
echo "Git branch is:"
git branch

I hope than some of you find this useful. And I apologise in advance
if this offends anyone as being too far astray from Cucumber.

Regards,

Matt Wynne

unread,
Aug 14, 2009, 11:13:52 AM8/14/09
to cu...@googlegroups.com

You can follow one of these tutorials and have the current branch
shown in your prompt, which is really good for your mental health:

http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/

cheers,
Matt Wynne

http://mattwynne.net
+447974 430184

byrnejb

unread,
Aug 14, 2009, 11:46:28 AM8/14/09
to Cukes


On Aug 14, 11:13 am, Matt Wynne <m...@mattwynne.net> wrote:

>
> You can follow one of these tutorials and have the current branch  
> shown in your prompt, which is really good for your mental health:
>
> http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-n...
>

It comes down to a matter of taste and flexibility. I specifically
wished for a method to invoke a script so that I could dynamically
customise my development environment (in the generic, non-Rails sense
of the word) depending upon where I was in my development trees. I
all I wanted was to continually show the active git branch then
certainly putting that information into the prompt is an excellent way
to accomplish this. In fact, that was my first remedy until presented
with the function above.

Regards,
Reply all
Reply to author
Forward
0 new messages