got a crush on drush
How I got drush to work on my macosx with mamp pro, and still my illustrator & photoshop works fine, how to do magick stuff with the terminal with out deleting to much, and learning not to use my pen to navigate my desktop...
This is very basic and written with the drupal front end geek that dont have the hots for a terminal window, so some of this might seem very basic, but hopefully this can get more of us front end geeks on the wagon of Drupal über power drush magick.
This obscure need to look into drush came from a comment last week that ment that designers really should look into drush - well okay then lets take a look at it!
drush?
"drush is a command line shell and Unix scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt."
ahemm... wtf... so why would a themeing frontend loving geek wanna use that drush thing? there isnt much html-css-design-javascript magic about "... command line shell and Unix scripting interface ..."
Well if it can save me a ton of hours of downloading, updating etc, then im all for it. Then theres so much more time to do fun stuff, like debugging ie or getting a cold brew
lets get drush
Download drush from drupal.org and unpacked it then place it somewhere on your mac
I have place the drush folder mine in my home dir (which is /mortendk/)

Remember to replaced [HOME] in your own install ;)
The drush folder dont have to be in your drupal installation, cause its really just a bunch of scripts that the terminal (or cli as the nerds calls it) uses. So no worries
fix permissions
Make the 'drush' command executable:
Following the drush manual
says that drush needs to "Make the 'drush' command executable:" ahem ooh well that basically means that you need to change some of the permissions
So open the terminal app
copy this into your terminal:
$ chmod u+x /Users/[HOME]/drush/drush
and hit return - now thats permission thing should be outta the way.
The .bash_profile adventure
My knowledge of this is not so big (aka not existing) but a .bash_profile file gives the terminal all kinds of presets for paths, and other stuff This is set so its gonna be easy to fire off drush commands from ther terminal else you have to write "/path/to/drush/drush" + the command instead of just drush + command. to get the magic to happen
(if you have a better explanation i would love to hear it!)
Bit back to the terminal and get that path thing to work:
- make sure we are in our home dir
this command will get you home: "$ cd ~" - open up a bash_profile file in the terminal do this "nano .bash_profile"
and then put this in
alias drush="/Applications/MAMP/bin/php5/bin/php /Users/[HOME]/drush/drush.php"
export PATH=/Applications/MAMP/bin/php5/bin:$PATH
Hopefully you gonna get a window that looks like this:

To actually save this hit ctrl-x that will take you to a new "page" in the terminal where you say "Y" for yes to saving the .bash_profile - test it
so lets check it out try to do a "drush" in your terminal - hopefyll it gives you something like this:

Drüsh Rocks
okay so lets make something with this drush:
In the terminal do this: make a new folder (teststuff) and download drupal to that folder with a single command: dl drupal
- $ cd sites (go to the site folder)
- $ mkdir teststuff (make a new folder called teststuff)
- $ cd teststuff (go to the teststuff folder)
- $ drush dl drupal (download drupal into the teststuff folder)
- wait a little bit
- "Project drupal (6.14) downloaded to /Users/mortendk/sites/teststuff/.[success]"
So that was pretty öwesome (yup thats awesome +1) It really begins to be really cool when you have a working drupal site. Before we go down that road lets just fix the memory in the mamp so we can kick some ass.
Memory mamp fix
Mamp comes with its php memory set to 8MB ... ahem so lets just fix that - else you will end up with a bunch of errors in the terminal and youll end up whining in the corner (or on IRC )
The problem here is that if you uses mamp as your webserver, the terminal cant really figure out where it should read the php configuration from as its described here
So to win the battle with memory problems in you php installation you need to do a little fine tuning of the php.ini files inside the mamp installation - its pretty simple to fix in mamp go to the mamp/conf/php5/php.ini
and search for "memory_limit" change that to something ass kicking like
memory_limit = 512M
more Drush
To get drush to work with the your drupal site you need to navigate into your drupal site so in this setup i just do something like:
cd sites/drupal
and now you ready to rock with drush:
- drush status
status of the drupal installation - drush update
update all the modules - yeah baby!
- drush cron
run cron on the site - drush cache clear
clear the cache
sharing the love
Im pretty sure theres a hell of a lot more cool ways of using drush -pretty sure the comments will be full with ideas ;).
I just wanted to share this with the rest of the world - now I have a place to find out how to get it to work again...
So to get all this comment line terminal crap to work I had to work a little (mostly with beeing frustrated) and rely on loads of help from the drupal community, looks like i had some points on the drupal karma account so thanx @mikl, @beeradb, @rightsprocket, @jacine, cll, & @threehz that used their time to help me through this experience -and not to forget moshe, owen & adrian who made this tool that made me use a terminal by my own free will ;)
resources
- drush readme
- modules that supports drush
- screencast: Installing and Getting Started from civic action
- screencast #2 rom civic action
- offcourse theres always the more beer argument ;)
*yeah ! tee's
Terminal resources
a guide for us that a terrified of that terminal:
* http://www.osxterminal.com
Lullabot documentation Rock star @add1sun is doing a bunch of videos about the cli :):
* http://www.lullabot.com/videocast/command-line-basics-moving-around
* http://www.lullabot.com/videocast/command-line-basics-copy-move-delete
* http://www.lullabot.com/videocast/command-line-basics-permissions-and-ownership





Pingback
Couldn't Agree More
Totally, totally, yes, yes, yes...
It was quite a challenge as a themer to get it up and running.
Now that I have it, I can't live without it...
Great write up!
Great writeup
Morten,
Thanks for breaking down drush installation in a couple of easy to follow steps.
Here are a couple of easy drush commands that I find myself using a lot:
download a module
drush dl [project_name]
install it
drush enable [module_name]
hop onto site's SQL database
drush sql cli
clear caches
drush cache clear
And if you want a hot Drush Tee like Adrian or Cary in the opening picture, there you go:
http://barthy.spreadshirt.com/i-heart-drush-A4552778
Drush FTW!
Yeah! Drush the apple
Hey Morten,
thx for your writeup. I followed your wtfs on twitter but i didn't expect that you come up with a kewl tutorial like this. Can't wait to get home and try this sutff out.
Cheers,
McGo
MAMP is a piece of shit. It
MAMP is a piece of shit. It drove me up the wall for a year until I finally got frustrated enough to try Zend Server CE. It rocks and I'll never look back. It takes a bit of time to move all your sites from one to the other, but it's not a requirement, you can use both on the same machine.
Pingback
The .bash_profile adventure won't work on All-Versions-HEAD
If you are using the All-Versions-HEAD, the step which you described in "The .bash_profile adventure" part won't work since calling the drush.php directly is not possible anymore
and perhaps this change might appear in the 'ALL-VERSION' the next time,
@see http://drupal.org/node/586466.
Then you have to call the shell script 'drush' which is also located in the drush folder or prepend 'php' to /path/to/drush.php to avoid a lot of frustation or just place the shell script somewhere within $PATH.
I realized this change by myself with a lot of pain in the ass, no drush only errors ;(
Although a great article which spreads the drüsh spirit!
dude head is in dev...
its scary enough to go into the terminal, so i wouldn't dare to use a head version ;)
Actually I found out that the might drush developers have made a lot of trix to look for mamp installations, so it should actually be even easier to install than this walkthrough...
yes, it is but...
yes, it is but since the dev supports aliases, like 'en' for 'enable', i need it - less typing more fun :D
and cc for clear cache? that
and cc for clear cache?
that would be sweet ;)
yes
yes it is and i think, thats why we <3 drush :D
and the fact that drush gives
and the fact that drush gives you that insane feeling of über power
and my download folder isnt full of old modules anymore ;)
Is the Pro version of MAMP necessary?
I have a non-Pro version of MAMP installed. Is the Pro version necessary to your instructions? To running Drush? Thanks for the tutorial. I've been meaning to install Drush. Will try as soon as this question is answered.
mamp should work
nopes its should be just as good with a basic mamp
The trick is to make sure that the mamp php have enough of memory
Thanks
I'll give it a try!
Glad you've come to the darkside.
And by darkside I mean the black terminal window.
If I wasn't following you on twitter I would have been very surprised to see this article, considering the comment you made the other day.
"if you only have the needs for clearing cache then i would argue that theres absolutely no reason for a themer to add drush to his arsenal of tools (afaik drush an develpers powertool)"
Do you wish to retract that statement? Nice writeup on how to get this installed, more people should be using Drush.
aheeem - goddamit heres my
aheeem - goddamit heres my own word being used against me. Still stand by them
it all depends on the need:
If the need is only to clear the cache then i would prefer to just use a point & click like the devel module - or having a separate window with /admin/settings/performance page and using the clear cache - or using zen like settings in the theme to clear the cache at every page load.
But if the need is to install a bunch of modules, update the site and doing all these "development" sexy moves, then drush is the bomb. No doubt about that. - but its not a "themer" tool - But its goddamn awesome!
I see the themer as the creative person in the middle between the developer, project manager, client and maybe the designer (if there is one)
Yup off course it maybe comes as a surprise, but if theres a new power tool in town that is actually usable for "normal" people - well then I would be a fool not to use it.
The other thing is that the more we front end drupalisticas learn to use developer tools, the easier it is to understand what it is "they" are doing on the other side.
Hopefully that will end up with some cli loving nerds to appreciate the wonders of UX, graphix and general design awesomeness :P
Awesome writeup! Thanks!
And I'm just noticing now: Adrian is user 1337? How effing cool is that?!
More dl coolness
Excellent post!
one thing to watch when you are using drush to enable some modules, like cck, is that the actual module name might be different than the folder/project name and that there might be multiple modules.
So for CCK, instead of :
drush enable cckyou would use:
drush enable contentOr to enable Views, you would use:
drush enable views_uiwhich will enable both Views and Views UI
The best way to figure out what modules are in a project is to list the contents and look for the .info files.
For example:
ls sites/all/modules/cckshows that there is a .info file for content and that there is a modules folder. Inside the modules folders, you'll find more .info files.
The actual dl coolness
So the reason I called my last comment dl coolness was because I was going to say this:
Someone up there mentioned that you can use
drush dlto download modules... you can also use it to download themes like:drush dl zenor you could use it to download a huge list of modules and a theme at the same time
drush dl cck views admin_menu zenDrüsh is soo 1337
yeah thats pretty goddamn cool.
Especially when I showed that download druapal + modules + themes in 2 see what i can do in 2 lines demonstration to the masses at the office today ;) - instant win!
Damn I can feel the darkside comming over me ... wonders if my textmate can run as a cli ?
Needed this a few weeks ago!
Except I'm using WAMP (Zend Server), which I eventually figured out using these instructions: http://drupal.org/node/330023
Not sure if there's another way around downloading the 3 external applications, but it works for me now so I can't complain.
Unfortunately I still use Cord to connect to my web servers, as I still can't figure out how to get Mac's Terminal to connect, but that's not Drush's fault.
Coda has a built in terminal
I use Panics Coda and it has a nice built in terminal window that allows you connect to your server within a nice colour coded terminal window... its also got svn built in so its easy to update your repository files when you have made changes.
So far it seems to me to be ideal to handle a svn/drush local/staging/production environment.
Glad to see you spreading the drush love, can't wait to see your reaction when you get Aegir added to your workflow, hahaha will never open your ftp client again and I guarantee you will never stop going on about how great Aegir is...
Pingback
thanks! I'm so close but need a bit of guidance
I'm so happy to have found your site. I'll be sure to check back often.
I believe I'm nearly set to begin experimenting with drush thanks for your instructions. But I'm having a slight issue - when I enter the command drush terminal responds with "-bash: drush: command not found" BUT! if I: move into my drush directory (cd drush) and enter the command "./drush" I see all of the examples, options, and commands. I'm no expert with terminal. I'd be extremely grateful if someone could help me push this along to complete success! Many thanks.
The coolest part
You're supposed to be rock 'n' roll Morten, then you need Visor, the Duke Nukem 3D style dropdown terminal! Write some code > Hit the §-button (or whatever is to the left of 1 on a DK keyboard) to get your fancy terminal > press up for latest command (which of course is "drush cc") -> enter and done!
Looks like this http://avipar.googlepages.com/Visor.jpg and can be downloaded here http://docs.blacktree.com/visor/visor
hot damn
its awesome :)
thanx for the tip
Pingback
If you regularly use drush to deploy drupal applications
If you regularly use drush to deploy drupal applications you may want to check out www.drupalmashup.interestsphere.com. The site will allow you to choose which projects(modules,themes) to generate drush commands for, option to generate enable commands and to specify --destination parameter.
List of drupal projects is updated regularly from drupal.org
Warning!!!
The drush shirt makes one look fat. Adrian and I are actually quite svelte.
Great stuff Morten!
Great stuff Morten, just what I was looking for.
One point from my experience, after creating the bash_profile I had to restart terminal before the drush command would work.
Cheers, looking forward to more drush posts!
Tom
New Drusher
Thanks for the great write up, i am now a dedicated Drusher!