If you regularly use the Terminal to modify or manage files in the filesystem, it may be helpful to be able to select a file in the Finder and open it directly in a specified Terminal editor such as vi, pico/nano, or emacs. While you can always launch a Terminal window and enter the command to launch the file in the desired editor, there is a way to do this directly in the Finder.
Luckily, like most Terminal commands, common text editors use the syntax "command targetfile" to launch and target a file. Using this, you can implement a system service that will grab a selected file and pass it to the Terminal to run in the desired editor program. Here is how to do this:
Open Apple's Automator program.
Select "Service" when you get the option to choose the type of file to create.
Make sure the input variables (at the top of the workflow window) are set to "Files or folders" and set the application to be the Finder.
Locate and add the Run AppleScript action, and drag it to the workflow.
Replace the line "(* Your script goes here *)" with the following two lines:
set thePath to POSIX path of input
tell application "Terminal" to do script "pico \"" & thePath & "\""
The current command will use the pico editor, but if you want to use vi, emacs, or another editor then change the text "pico" to the name of the editor of your choice. You can optionally also remove the "return input" line.
Save the service, and give it a name (such as "Open with pico").
Note that the Services option is only available for Snow Leopard users. If you are using OS X 10.5 Leopard, then you can just create a new work flow in Automator and choose "Save as plugin" from the File menu to do the same thing. Save it as a plug-in for the Finder, and it will then be available in the More > Automator submenus of the contextual menu when you right-click a file.
With the service saved, you can now right-click on any file in the Finder and select the service in the Services contextual submenu, and the file will open in the Terminal. Be sure the file can be read by the editor before you use the service; otherwise you may see a lot of garbled text appear in the Terminal window.