This will build in the current directory minus the .c extension.

TM_FILENAME_BASE=`echo $TM_FILENAME | cut -d\. -f1`
#echo Base Filename: "$TM_FILENAME_BASE"

echo '<pre>'
cd "$TM_DIRECTORY"
cc -I. -o "$TM_FILENAME_BASE" "$TM_FILENAME"
if (($? >= 1)); then exit; else echo "build successful"; fi
echo '</pre>'

# cc must be in your path, if you've installed OS X gcc package you should be fine

This will build and run the file your working on and display the output.  The object file is filename minus the .c extension.
TM_FILENAME_BASE=`echo $TM_FILENAME | cut -d\. -f1`
#echo Base Filename: "$TM_FILENAME_BASE"

echo '<pre>'
cd "$TM_DIRECTORY"
cc -I. -o "$TM_FILENAME_BASE" "$TM_FILENAME"
if (($? >= 1)); then exit; fi
./"${TM_FILENAME_BASE}"
echo '</pre>'

# cc must be in your path, if you've installed OS X gcc package you should be fine

'njoy,
Mark