November 9th, 2007
If you are a web developer, you undoubtedly have needed to edit a system config file from time to time. Your choices in the terminal are nano, and …well, nano. If you happen to have BBEdit installed, then you can use that as well. However, BBEdit costs $125, which is pretty steep if you just need a text editor.
Yee-ha! (sorry. I couldn’t help myself. I am from Texas, y’all). Turns out that BBEdit has a little brother called TextWrangler that has the advantage of being both free and powerful. Me rikey things that are free.
Next, when you install it, be sure to say ‘yes’ when asked if you want to install the command line tools. This integrates TextWrangler with the Terminal so that you can launch from the command line. Let’s say you want to edit your hosts file. You’d simply type:
sudo edit /etc/hosts
It’s that simple.
Now, let’s Automate this for frequently edited docs such as your Apache config or hosts files. Launch Automator and create a new, Custom workflow.
Add a Run AppleScript action. Enter the following:
do shell script "sudo edit /etc/hosts" password "[YOUR ROOT PASSWORD]" with administrator privileges
Save the workflow as an application. Now, you can edit these protected system documents with ease.
Tip: Use QuickSilver to launch your Automator script with a few keystrokes.