Introducing subDrush: a Sublime Text 3 interface to Drush

June 25, 2013

Sublime Text is becoming a popular choice for Drupal developers, and for good reason - it's a fantastic code editor, works great with PHP (especially the new code navigation features in Sublime Text 3) and it's easy to configure for Drupal development.

Having come to Sublime Text from Vim, one thing I missed in Sublime Text was the proximity to the command line, and especially Drush, when working on a site. The ability to make some changes and, for example, type !drush cc all or !drush sql-query is really useful and saves me time switching contexts between the terminal and the editor. (Incidentally, the Vim Plugin for Drupal has nice Drush integration, and was a helpful conceptual guide when writing this plugin.) To fill this gap, I wrote the subDrush plugin for Sublime Text 3. The plugin provides a **sub**set of **Drush** functionality within ST3. The idea is not to provide support for all Drush commands, because there are many Drush commands where this doesn't make sense (e.g. rsync, sql-sync) - but there are quite a few that are convenient to run from within the code editor, and some are even more functional, in my opinion, when run from within ST3 (like the php-eval command) than in the terminal. Hats off to the developers of Drush 6 who have made it a breeze to integrate Drush with third-party applications. The initial release of subDrush (0.1) contains support for the following commands:

Command Description Type
cache-clear Clear a specific cache bin core
cache-clear all Clear all caches core
core-status Provides a birds-eye view of the Drupal installation core
watchdog-show Displays the 10 most recent watchdog entries core
variable-get Displays the value of a Drupal variable core
cron Invokes cron for open Drupal director core
php-eval Evaluates selected text in the bootstrapped Drupal site core
php-script Executes open buffer as PHP script after Drupal bootstrap core
pm-list Show a list of available extensions (modules and themes) core
alias-edit Edit the Drush aliases (current site or choose from list) custom

Access the commands by opening up Sublime's Command Palette (Ctrl + Shift + P) and typing "drush".

All of the commands run asynchronously, so, for example you can execute Drush: PHP-Eval and continue with your work - when the results of executing the code are ready, they'll be presented in the build output panel. You can also run multiple subDrush commands at once (e.g. Drush: Cron followed by Drush: Watchdog Show to see the results).

Here is a brief screencast walking through some of the features of the plugin (please select HD when you're watching). Note that since the screencast was recorded, I've added syntax highlighting to most commands so the results returned from Drush are easier to review:

Support for additional commands is planned for future releases - check out the issue queue to get more information and submit requests for new features.

To install the package, you'll have to clone the git repo into /Packages. (Update: The plugin was added to Sublime Package Control, so installation is as simple as going to Package Control: Install Package and typing subDrush.) You'll need Drush 6 and Sublime Text 3 for the plugin to work correctly.

Head on over to the project page to find out more about the plugin and documentation for its usage - I hope you find it useful in your Drupal development!

Comments

Permalink

Thanks for extending the Drush ecosystem. This looks awesome.

FYI have a look at the newish core-conf command which helps editing alias files, drushrc files, settings.php files, etc. It has support for $EDITOR so should open up files for editing in ST though I am not familiar with its plugin system.

Permalink

Great one... i was finding about core-status. here, i got everything sublime text. best one.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.