Since Drush usage seems to be spreading in the design/themer community, it might be useful to have drush support for building sub-themes and choosing layout files.

#5 zen.drush_.inc_.txt2.75 KBmarcvangend
#3 zen--drush.1.patch3.06 KBjix_
Membership dollars fund testing for the Drupal project. Drupal Association Learn more


seutje’s picture

yes, this would be awesome

Ink Ribbon already does this, might draw some inspiration from that

jix_’s picture

I've made a Drush command lately for my own Zen starter kit, although it's very basic at the moment. (It only copies the starter kit and renames things where applicable.)

If something like this gets into Zen, it would be really awesome if, somehow, one could use that single command for their own starter kit as well. Something like drush zen "My theme name" --kit=cassette

That way I wouldn't have to create a silly fake theme just to be able to execute that command for my own starter kit, for example.

I'll make a patch from my command so it works for Zen, maybe from there we could start improving and extending it.

jix_’s picture

Status: Active » Needs review
3.06 KB

First stab

marcvangend’s picture

subscribe. this would be awesome.

marcvangend’s picture

Status: Needs review » Needs work
2.75 KB

I gave it a quick try tonight. At first I got a 'deprecated' error because you used the split() function on line 37 (I'm using php 5.3). I changed split() to explode() to fix the bug, and join() to implode() because it seems more consistent. I'm attaching the changed file as .txt. After that, my sub theme was created and so far everything looks fine.

sirkitree’s picture

where does this file belong?

marcvangend’s picture

From the Drush readme.txt:

Drush ships with a number of commands, but you can easily write
your own. In fact, writing a drush command is no harder than writing simple
Drupal modules, since drush command files closely follow the structure of
ordinary Drupal modules.

See for light details on the internals of a drush command file.
Otherwise, the core commands in drush are good models for your own commands.

You can put your drush command file in a number of places:

- In a folder specified with the --include option (see above).
- Along with one of your existing modules. If your command is related to an
existing module, this is the preferred approach.
- In a .drush folder in your HOME folder. Note, that you have to create the
.drush folder yourself.
- In the system-wide drush commands folder, e.g. /usr/share/drush/commands

In any case, it is important that you end the filename with "", so
that drush can find it.

sirkitree’s picture


Yes. I placed this in my ~/.drush folder for it to work, but only after trying to run the patch in the theme directory, effectively creating a file within /sites/all/themes/zen/ - which will not work. Since (IMHO) it's a little bit different for a theme to provide a file and it doesn't seem to work when you do, we should have it documented somewhere within this theme as to where to place it so that when this file ships with the theme it's known that you have to actually move it.

Or am I missing something and it's actually supposed to work when you have the file within your theme? I tried Drush 3.3 and 4.1 with the file in the theme folder and neither picked it up.

Otherwise, works as advertised :)

Chris Charlton’s picture

Component: PHP Code » layout.css

The `zenophile` module already offers this capability.

JohnAlbin’s picture

Component: layout.css » PHP code
Status: Needs work » Fixed

Ok. I got the sub-theme creation drush command working.

To make this really work though, we'll need to get this patch into Drush 4.5: #535788: Check sites/all/themes for * files

marcvangend’s picture

Excellent, thanks John!

(Makes me wonder if there are more Zen features we could/should support in Drush. Maybe toggling the zen_rebuild_registry and zen_wireframes settings? If anyone is interested: start a new issue for it.)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

KrisBulman’s picture

this patch shows as it's been backported to 4.

what's the proper syntax to create a zen subtheme using drush?

marcvangend’s picture

Quote from the code:

  27     'examples' => array(
  28       'drush zen "My theme name"' => 'Create a sub-theme, using the default options.',
  29       'drush zen "My theme name" my_theme' => 'Create a sub-theme with a specific machine name.',
  30     ),

Hope that helps.

KrisBulman’s picture

Version: 7.x-3.x-dev » 7.x-3.1
Status: Closed (fixed) » Active

drush 4.4
zen 7.x-3.x

zen/zen-internals/ exists

$ drush zen "themename"
$ The drush command 'zen test' could not be found.
$ drush zen
$ The drush command 'zen' could not be found.

copied the file to drush/includes/

same problem

KrisBulman’s picture

Version: 7.x-3.1 » 7.x-3.x-dev
KrisBulman’s picture

After reading the drush readme file, i created a .drush folder in my home folder and put the file in there and this functionality does work.

But considering post #10, shouldn't it just work without the above approach?

marcvangend’s picture

KrisBulman: the patch mentioned in #10 was committed to the Drush-4.x branch in april, after Drush-4.4 was released. In other words, it should work with the latest dev version (, not with 4.4.

KrisBulman’s picture

Status: Active » Closed (fixed)

thanks for the update, worked like a charm

$ rm -rf  $HOME/.drush/ 
$ cd  sites/all/themes/
$ drush zen "newtheme"
$ Starter kit for "newtheme" created in: sites/all/themes/newtheme
Sumeet.Pareek’s picture

The zen command for drush failed on me with the below error

drush: The directory "/var/www/example//STARTERKIT" was not found.
Drush command terminated abnormally due to an unrecoverable error. 

Digging into the file I notice the below line causing the error

  // Determine the path to the new subtheme by finding the path to Zen.
  $zen_path = drush_locate_root() . '/' . drupal_get_path('theme', 'zen');
  $subtheme_path = explode('/', $zen_path);

So I realized that the command fails when you try to create a subtheme before you enable zen. Because without enabling zen theme drupal_get_path() return nothing for its path. I think this should either be fixed (by putting together the path without using drupal_get_path()) or there should be a mention in 'drush help zen' about the command working only when zen is enabled first. There might be very few like me who would try to create subtheme files before enabling zen, but doesn't it still sound like a good idea to make the changes.

jantoine’s picture

I ran into the same issue in #21. Thanks to @wikidkaka for documenting the problem!

AdrianB’s picture

Component: PHP code » layout.css

Same here, thanks wikidkaka @ #21. I hadn't enabled zen and got that error message.

Chris Charlton’s picture

Issue tags: +drush

One minor issue I saw recently was when I tried creating a Zen sub-theme via Drush where the theme name was empty. The files were generated but there wasn't any error checking to see if the theme name was empty before dumping files into my sites/all/themes folder.