Speaker For The Diodes - Post a comment

Jul. 11th, 2010

03:32 am - Mac OS X question: startup command for an instance of Terminal?

I'm running Mac OS X 10.5.8 on a G4 processor.

I may or may not already have Terminal running.*

I want to double-click the icon of a text file (with one of a particular set of filename extensions**) and wind up with that text file open in vi inside a Terminal window. I'm willing to have the icon I click be a 'bundle' with the target text file inside it, instead of clicking the text file directly, if that's what it takes. I'm pretty sure kinda sure that if I can pop open a new Terminal window with vi running inside it from a shell script (or a C program that uses exec() or system()), I can get a GUI event to invoke that. But so far, I haven't found a way to pass startup commands to Terminal. If I were to use xterm instead of Terminal, the trick in a script would be

xterm -e vi {FILENAME}

but I've not found an equivalent for the Terminal app yet. Anybody out there happen to know how to do this (or know for sure that it can't be done)?

[*] Okay, I almost always have multiple Terminal windows open, because tcsh gets lonely and I have to keep it company (*cough*) because even with as nice a GUI as a modern Mac, I still find the shell really, really, really convenient for a lot of what I do. The point is that I'm trying to initiate this particular event from outside of Terminal and wind up with something running inside of Terminal.

[**] Just *.abc and *.abp for now (though hey, why not extend it to *.txt and a few others once I get the basic concept working?), so it doesn't have to be able to distinguish text files from others files be peeking at their contents, just check an extension.

Reply:

From:
( )Anonymous- this user has disabled anonymous and non-friend posting. You may post here if dglenn lists you as a friend.
(will be screened)
Identity URL: 
Username:
Password:
Don't have an account? Create one now.
Subject:
No HTML allowed in subject
  
Message:
 
Notice! This user has turned on the option that logs IP addresses of anonymous posters.