At work and on my home computers, I typically store all my websites in a single directory. I create and check out subversion repositories into this directory. To speed up my workflow, I started adding aliases to my ~/.bash_profile file, e.g.
alias chiron='mono /Applications/Silverlight/sdl-sdk/sdlsdk-0.4.0/bin/Chiron.exe'
alias lsa='ls -al'
alias mate='open -a TextMate.app .'
alias sites='cd /Library/Webserver/Documents'
alias sl='/Applications/Silverlight/sdl-sdk/sdlsdk-0.4.0/script/sl'
alias slserver='/Applications/Silverlight/sdl-sdk/sdlsdk-0.4.0/script/server'
In the sample above, when the bash shell starts (firing up Terminal), I can now simply type
$ sites
To move into my sites directory. So, my usual morning start-up routine might involve something along the lines of
$ sites; cd Typeoneerror; svn up .; mate .
Which would jump to my sites folder, move into the Typeoneerror repository checkout, run svn update, and then open the project in TextMate.
Anyway – long story short – I decided to dabble around in some bash scripting and automate this process, creating a program that allows quick access to updates and open TextMate projects from anywhere in the Terminal shell. The result is my first bash “app”, sup. Sup allows you to set a “base directory” for you websites and then update and open projects from anywhere in the shell. For example, from any directory, I can type:
$ sup Typeoneerror
At revision 47
And the following happens:
– The Typeoneerror repository checkout is updated.
– TextMate opens the Typeoneerror directory in a new project
Doesn’t matter where you are (your current working directory). Of course, it’s very simple, but I’ve found it quite useful. The program also has a few flags:
Options
-c Specify path to your sites folder
Calling sup with this flag is the first thing you will do in setup. This takes a absolute path parameter which is the path to where all your websites live. For this example, I installed sup in ~/bin:
$ sup -c /Library/Webserver/Documents
Default path changed to /Library/Webserver/Documents in /Users/ben/bin/.sup-config
This creates a config option that tells sup the root of your websites. The next time you use sup it will look for a repository in the configured folder. The default sites path is “.” which translates to the current working directory.
Flags
-h Displays the help docs
-i Ignores updating the externals in the subversion checkout (–ignore-externals).
-t Ignores opening the project in TextMate at the end
-v Tells you what it’s doing as it does it – AKA verbose
-w Tells you where your sites folder has been configured
Examples
# update a subversion repository in a folder called "Folder"
$ sup Folder
# update Folder,
# ignore externals on svn up
# don't open in textmate
# display verbose logging
$ sup -tiv Folder
# update Folder without updating svn:externals
# then change directories into the updated directory
# (cd only works when running the script as "source")
$ . sup -i Folder
Installation and setup
- Download the bash script
- Extract the zip and copy sup to ~/bin
- Make sure ~/bin is in your path. You can simply add the following to ~/.bash_profile if ~/bin is not in your path already:
export PATH=$PATH\:~/bin
- run setup:
sup -c /Your/Path/To/Website/Checkouts
As always, I’m no unix pro; my forte is Actionscript and PHP. If you think this program is ridiculous in any way and needs fixing or you have any suggestions, please comment or contact me!