Drupal Technical
How to enable multiple Drupal themes using the bash command line?
The default method of changing a Drupal theme using the graphical Admin interface is familiar to most Drupal users. However a Drupal user is limited to changing only one theme at a time using this method and it is also slightly time consuming. What if you want to enable more then one theme at a time? Drupal provides a quicker way to change the theme using the bash command line. Read on to know how to enable multiple Drupal themes using the bash command line
- First we have to install drush on your server. Drush is a command line interface for accessing and working with Drupal
- After installing Drush lets check out all the existing themes in our Drupal site
- Type the following command from your Drupal server
~/drush/drush pm-list --type=theme
- In sites/all/themes folder type
drush pm-list --type=theme
- This will display all themes in following order
- Package
- Name
- Status
- Version
To enable a single theme with confirmation
- Type the following command from your Drupal server
~/drush/drush pm-enable themename eg: ~/drush/drush pm-enable vert
- In sites/all/themes folder type
drush pm-enable themename eg: drush pm-enable business_blog
To enable a single theme without confirmation
- Type the following command from your Drupal server
~/drush/drush pm-enable themename --yes eg: ~/drush/drush pm-enable vert --yes
- In sites/all/themes folder type
drush pm-enable themename --yes eg: drush pm-enable black_blog --yes
List all themes with the associated info
- Type the following command from your Drupal server
~/drush/drush pm-list --type=theme | tr -s ' '
- In sites/all/themes folder type
drush pm-list --type=theme | tr -s ' '
Cut each column
- Type the following command from your Drupal server
~/drush/drush pm-list --type=theme | tr -s ' '| cut -f1 -d' ' ~/drush/drush pm-list --type=theme | tr -s ' '| cut -f2 -d' '~/drush/drush pm-list --type=theme | tr -s ' '| cut -f3 -d' '
- In sites/all/themes folder type
drush pm-list --type=theme | tr -s ' '| cut -f1 -d' ' drush pm-list --type=theme | tr -s ' '| cut -f2 -d' ' drush pm-list --type=theme | tr -s ' '| cut -f3 -d' '
Display all theme names
- Type the following command from your Drupal server
~/drush/drush pm-list --type=theme | tr -s ' ' | sed s/.*\(//| sed s/\).*//
- In sites/all/themes folder type
drush pm-list --type=theme | tr -s ' ' | sed s/.*\(//| sed s/\).*//
Write all the themes to a themelist file
- Type the following command from your Drupal server
~/drush/drush pm-list --type=theme | tr -s ' ' | sed s/.*\(//| sed s/\).*// > themelist
- In sites/all/themes folder type
drush pm-list --type=theme | tr -s ' ' | sed s/.*\(//| sed s/\).*// > themelist
- Make sure that the file contains only theme name and not any other content. You can edit the file using following commands
less themelist nano themelist wc -l themelist
Display all the themes from themelist file
-
for i in `cat themelist`; do echo $i; done
Enable all the themes (with confirmation required)
- Type the following command from your Drupal server
for i in `cat themelist`; do ~/drush/drush en $i; done
- In sites/all/themes folder type
for i in `cat themelist`; do drush en $i; done
Enable all the themes (without confirmation)
- Type the following command from your Drupal server
for i in `cat themelist`; do ~/drush/drush en $i --yes; done
- In sites/all/themes folder type
for i in `cat themelist`; do /drush en $i --yes; done
Hope you have find this article useful. Feel free to give your feedback via the comment form below .