views:

53

answers:

3

I started using Haml/Sass thru Rubygems recently, and I'm really liking it (although that doesn't have much to do with my question)...

I would like to create a simple script I can throw in the root directory of each of my projects that will launch terminal, cd to my CSS folder, and run sass. so essentially a script that:

cd ~/path_to_here/css/
sass --watch style.scss:style.css --style compact

I'm not really sure the best way to go about this, anything involving the command line is always slightly out of my comfort zone. Many thanks.

A: 

You could write a applescript that would launch terminal, and call a shell script.

Applescript tell application "Terminal" do script "pushd /blash/sassstup.sh" end tell

shell script: cd cssfolder /bin/sass --watch style.scss:style.css --style compact

Thomas Vincent
A: 

Consider using Compass for managing the building of your Sass files: It has a script for watching changes in all your project files and setting up all the output parameters.

You can create a simple text file with the extension .command which will make it a double-clickable script in OSX:

#!/bin/bash
compass watch
Andrew Vit
A: 

This script won't open the Terminal for you; but it will give you a shortcut to do the repetitive task of changing to the project directory and calling the compass watch command. (I highly recommend you to use Compass which is a SASS compilation of Tools to make your life easier.)

Put this inside your ~/.profile file and restart your terminal:

alias watch=compass_watch_project
function compass_watch_project() {
  cd ~/Dev/ruby/$1;
  compass watch
}

Remember to change the ~/Dev/ruby/ to your directory path.

After this you can easily do a watch myProject.

Hope it helps.

kuroir