ninetydegrees: Art: self-portrait (Default)
ninetydegrees (90d)☕ ([personal profile] ninetydegrees) wrote in [site community profile] dw_dev_training2013-06-16 11:16 pm
Entry tags:

Very basic scripts for newbies

I have two scripts I use all the time and which have saved me much grief and hair pulling. I was told there were worth sharing so here I am doing just that. :)

The first one just checks which branch you're on both in dw-free and nonfree (it's basically git branch with a bow):

#!/bin/bash
echo "..."
echo "dw-free"
echo "..."
cd $LJHOME
git branch

echo "..."
echo "dw-nonfree"
echo "..."
cd $LJHOME/ext/dw-nonfree
git branch



See? There's nothing particularly smart about this but I run it every time I start working on something. This goes into ####-USERNAME/bin on your hack and is made executable with chmod ugo+x ~/bin/SCRIPTNAME

The second one just checkouts develop for me on both branches and brings me back to /dw. See alierak's comment for an actual working way of doing this. :)

You can of course modify them to better fit your workflow or use Jeshyr's omnibus script instead. If you have interesting scripts, do share them in the comments please!
alierak: (Default)

[personal profile] alierak 2013-06-16 11:05 pm (UTC)(link)
Note: using cd in a script does not normally change directory in the shell from which you run the script. In order to make it actually leave you in a different place than you started, you'd have to run it with ". scriptname" (dot space scriptname) to interpret it within the current shell instead of a subshell.

That said, while at YAPC I banged my head on git for a while when trying to patch EmailPost.pm and being completely unable to find it. Turns out my dwu script left me on the master branch, which is apparently a bad place to try to get anything done. I switched around the order of branch updates in my script so it leaves me on the develop branch.