Automate Terminal with Automator

If you are a mac user and do local development using MAMP you probably find yourself opening the terminal quite often to edit your settings.php file or adjusting permissions with the command line.

This involves at minimum typing cd /Applications/MAMP/htdocs That is, if you can remember the folder structure. If you can't, throw in some ls cd pwd if you forget exactly where it is and you are wasting precious time tediously typing directory names. Don't forget you can hit the tab key to auto-complete a directory name. For example type: cd Ap and hit the tab key and terminal fills in cd Applications for you. Instead of modifying your start-directory in terminal to always open to your htdocs folder, why not create an Automator Workflow that opens there instead? This way, you reserve your standard user folder in terminal when you need it and when you are doing web development work, you can click the workflow icon and it automatically opens the terminal to Applications/MAMP/htdocs Here is how:

  1. Start Automator
  2. Select "New Application"
  3. Under Actions/Utilities from your library select "Run Applescript"
  4. Drag the "Run Applescript" to your pane.
  5. Add this Applescript Code: on run {input, parameters} tell application "Terminal" activate do script with command "cd /Applications/MAMP/htdocs" end tell end run
  6. You can replace the "cd /Applications/MAMP/htdocs" with any directory you want.
Now save your application and drag it to your dock or your desktop. This way it is accessible quickly whenever you need it. You could even make it more elaborate and have automator open your settings.php file for you or other files as well. Hopefully this will speed up some of your workflow and help you automate with automator! You can download the application below as a .zip file. I've also included a handy icon you can attach to your workflow. Just download and extract the zip file.