This post is slightly geekier, and more hands on than most of my recent posts, but it follows the same theme: efficiency.
The life of a developer is fraught with repetition. Minimizing said repetition makes me very happy. The other day I noticed that whenever I start working on a project I start with the following routine:
- Open Terminal
- cd to the working folder for the project so I can pull the latest files from the Git repository
- Open the working files in TextMate.
After these steps, the process diverges, but those first three steps are constant. I keep my project files well organized so I have a hope in hell of remembering where things are, so even changing directories to my working files follows a pattern (cd projects/projectname.com/working).
Having followed these steps half a billion times, I decided it was time to streamline, so I wrote this very basic little script:
#!/bin/sh
mate ~/projects/$1/working
osascript<<END
try
tell application "Terminal"
do script with command "cd ~/projects/$1/working;echo \"You're now working on $1\""
end tell
end try
END
By typing that code into blank text file, saving it as proj, chmodding it to 755, and moving it to /usr/bin I got a little shortcut for starting projects. Now I just open terminal, and type “proj projectname.com”, and I get a terminal window cd’ed to the working files, and TextMate opened up to my project files.
Of course, this is a very simplistic implementation, I may add additional steps, such as automatically pulling the latest files from the repository, or opening up the log of most recent changes. Anything is possible. While this particular script may not be useful to you, I urge you to examine the tasks you perform regularly and experiment with what can be automated to save you time. Simple scripts like these, or those generated by Apple’s Automator are easy to make and save tons of time in the long run.
