A Simple Shell Command for Drupal CVS Checkouts

Drupal Modules

#!/bin/bash cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-$2 -d $1 contributions/modules/$1

There are lots of great Drupal productivity/development modules (e.g. drush, devel, coder) which, due to their nature as modules, need to be installed on each site you work on. If you work on a dizzying number of different Drupal sites, productivity improvements which are not site-specific are the most useful. NB: this post is geared toward Mac users.

For Textmate, I now have both the BoldSource bundle and the PHP Drupal bundle, which are both new. I also make great use of the Wim Leers command to instantly look up Drupal API functions from Textmate.

For the shell I sometimes use Steven Wittens' diff shortcut, and I also followed Textmate's instructions so that I can open files and projects in Textmate with the mate command (it always saves time to avoid Finder, whether via Quicksilver or command line).

If you ever (perpetually?) find yourself having to debug contributed modules, it is important that you always download your modules from cvs- otherwise you will not be able to submit a patch for your work and will soon find yourself fixing the same thing again for your next project.

Getting your modules from cvs is actually faster than downloading them from your browser and unpacking them into the right folder, but the cvs command itself can slow you down. For a while I have been using an alias to simplify checking out Drupal modules via cvs, but I finally got around to setting up a proper bash command.

I am pretty new to the wild world of command line geekery, but this is how I added a new command:

From your home directory, edit your .bash_profile filecd ~ mate .bash_profile (or use another editor: vi .bash_profile) (If you don't already have a .bash_profile file it will be created)

Add the line export PATH=/usr/local/bin:$PATH where /usr/local/bin will be the directory where you will add new commands. You can use a different directory if you please. Navigate to that path where you can add new commands.cd /usr/local/bin The commands are just text files where the name of the command is the filename. I call my drupal cvs module checkout command 'drcvs'. mate drcvsAdd the following: #!/bin/bash cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-$2 -d $1 contributions/modules/$1

Save the file and open a new shell. (You have to open a new shell for the .bash_profile changes to register.) You can now use the new command.

I use drcvs views 5--1-6 to do a checkout of views into my current directory. (I look up the version I want on the project page first.)

Ready to get started?

Tell us about your project