got a crush on drush

21 October 2009 mortendk

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:

  1. make sure we are in our home dir
    this command will get you home: "$ cd ~"
  2. 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
  3. 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

  1. $ cd sites (go to the site folder)
  2. $ mkdir teststuff (make a new folder called teststuff)
  3. $ cd teststuff (go to the teststuff folder)
  4. $ drush dl drupal (download drupal into the teststuff folder)
  5. wait a little bit
  6. "Project drupal (6.14) downloaded to /Users/mortendk/sites/teststuff/.[success]"

this command:

gives us this:

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

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

[...] got a crush on drush | morten.dk morten.dk/blog/got-crush-drush – view page – cached 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... (Read more)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... (Read less) — From the page [...]

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!

Anonymous 21 October, 2009 - 04:43

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!

alex_b 21 October, 2009 - 06:13

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

Anonymous 21 October, 2009 - 06:28

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.

dalin 21 October, 2009 - 08:38

Pingback

[...] el fichero, lo editamos y cambiamos el valor de memory_limit a 128 (por ejemplo). Más info en http://morten.dk/blog/got-crush-drush y en [...]

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!

Anonymous 21 October, 2009 - 12:31

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...

mortendk 21 October, 2009 - 13:41

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

fl3a 21 October, 2009 - 14:23

and cc for clear cache? that

and cc for clear cache?
that would be sweet ;)

mortendk 21 October, 2009 - 14:42

yes

yes it is and i think, thats why we <3 drush :D

fl3a 21 October, 2009 - 14:47

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 ;)

mortendk 21 October, 2009 - 15:12

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.

Marilyn 21 October, 2009 - 13:03

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

mortendk 21 October, 2009 - 13:36

Thanks

I'll give it a try!

Marilyn 21 October, 2009 - 15:20

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.

davexoxide 21 October, 2009 - 15:29

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

mortendk 21 October, 2009 - 16:00

Awesome writeup! Thanks!

And I'm just noticing now: Adrian is user 1337? How effing cool is that?!

Laura 21 October, 2009 - 16:43

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 cck
you would use:
drush enable content

Or to enable Views, you would use:
drush enable views_ui
which 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/cck
shows 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.

Lin Clark 21 October, 2009 - 17:02

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 dl to download modules... you can also use it to download themes like:
drush dl zen

or you could use it to download a huge list of modules and a theme at the same time
drush dl cck views admin_menu zen

Lin Clark 21 October, 2009 - 17:04

Drü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 ?

mortendk 21 October, 2009 - 17:11

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.

Laura Robeson 21 October, 2009 - 18:02

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...

Anonymous 23 October, 2009 - 13:52

Pingback

[...] básico de drush, en morten.dk (en [...]

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.

Brett 18 November, 2009 - 01:43

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

Emil 21 November, 2009 - 15:08

hot damn

its awesome :)

thanx for the tip

mortendk 24 November, 2009 - 18:30

Pingback

[...] but somehow I missed the major 2.0 update in June and that it works on Windows now. When I saw Morton’s Mac Drush post and revisited my Windows issue, and now I am a [...]

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

AnonymousDan 5 December, 2009 - 01:16

Warning!!!

The drush shirt makes one look fat. Adrian and I are actually quite svelte.

Anonymous 21 January, 2010 - 00:35

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

thomjjames 30 January, 2010 - 14:04

New Drusher

Thanks for the great write up, i am now a dedicated Drusher!

Anonymous 25 February, 2010 - 02:54

drush on mamp

Hi there, thanks for your tutorial. I may have missed a step here, but drush does work locally i.e while using mamp, but not on my server. What should I do ?

While using root access to my server of course my user name would change to root@server, does this mean I have to setup drush on my server for it too work ? For some reason I thought it could be done locally.

Chris 19 April, 2010 - 12:35

Weel it seems I needed to

Weel it seems I needed to turn off Safe mode in php.ini

Thankz

Chris 23 April, 2010 - 12:23

.bash_profile mysql commands

Thanks a lot! I got things set up locally with the help from this article.

As Tom mentioned, .bash_profile needs to be refreshed for the changes to take effect. If it's in your home directory you can use the command: source ~/.bash_profile

FYI, drush sql-dump command wasn't working and it told me command not found so I modified .bash_profile to include MAMPs path to mysqldump:
export PATH=/Applications/MAMP/bin/php5/bin:/Applications/MAMP/Library/bin/:$PATH

hairybrew 6 July, 2010 - 23:16

Pingback

[...] Instal·lació i configuració de Drush(2): http://morten.dk/blog/got-crush-drush [...]

Thanks

This tutorial makes me understand my problems and set up correctly drush, unvaluable ! Thanks !!!

Julien 17 September, 2010 - 11:29

Pingback

[...] ceux qui aimeraient installer Drush sous Mac voici comment faire Tags: Administration, Documentations, Drupal, Linux, [...]

Same tutorial with Xampp

The tutorial makes drush accessible for non-developpers but the problem is that I usually work with XAMPP and not with MAMP... so it would be nice give some more indications for XAMPP users ... I'm actually blocked at this point : "The .bash_profile adventure". Thanks!

Anonymous 17 April, 2011 - 21:19

thanks

I don't know what you made me do but now it works !! many thanks !

Anonymous 9 July, 2011 - 18:34

Pingback

[...] i configuració de Drush(2): http://morten.dk/blog/got-crush-drushComandes Drush: http://drupal.org/node/477684 actualitzacions Drupal drush mòduls utilitats This [...]

drush pm-enable

I started using the quickstart project drupal.org/project/quickstart and it makes wamp/mamp et al look like little sissys. I will never be the same. You don't have to worry about installing drush as it is all pre-packaged with a nice IDE and debugger even if you use it only for drush. Anyway I just wanted to mention after you install your site and drush dl your modules, you can use drush pm-enable colorbox content_taxonomy date diff email entity features field_collection to enable multiple modules at once without ever visiting a checkbox!!! Now THAT'S power.

stieglitz 12 December, 2011 - 07:32

Great Post

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work. Corals at Keppel Bay

atppty 27 April, 2013 - 17:38

Useful & Nice

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work. Corals at Keppel Bay

atppty 27 April, 2013 - 17:38

Great Post

Great Post. I have not been visiting the site recently. Took a visit again and there were some great comments on the site. Excellent post. Keep up the good work. the trilinq

atppty 6 May, 2013 - 12:13

Thanks for sharing it. I

Thanks for sharing it. I found this Information very interesting and informative! Keep sharing!I'll make sure to bookmark it and come back to read extra of your helpful info. brake booster

doankl 19 August, 2014 - 07:34

meladerm cream reviews

Good location, and some really good value from what you might otherwise expect when staying in a New York hotel. meladerm cream reviews

Anonymous 2 September, 2014 - 21:11
The content of this field is kept private and will not be shown publicly.
i went from journey to damn yankees Think i need a beer pretty soon 1 year 46 weeks ago
4,356

good Stüff

Mothership - a clean up the crap "theme"

Miro - a open atrium theme:
more info & comments

freya rocks

the progress for my premature daughter can be folllowed here:
Freya Rocks
sorry its in danish

Give some Love to the development of the mothership

Flattr this

User login

Recent comments

give some luv

drupal member ...

geek royale