eftychia: Me in poufy shirt, kilt, and Darth Vader mask, playing a bouzouki (vader)
Add MemoryShare This Entry

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.

There are 2 comments on this entry. (Reply.)
 
posted by [identity profile] austin-dern.livejournal.com at 05:56pm on 2010-07-11

I'm not positive because I haven't got anything I want run when I start up Terminal, but I believe you should be able to set what you like in the .login or the .bashrc or .tcshrc files in your ~ directory ... unless I'm misunderstanding you and you mean what code starts up a new instance of Terminal, in which case I believe that it's

/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal

... yeah, that seems to do it, although I don't see how to pass parameters into it. I'm afraid all I set my Terminal to do is start the shell which offers suggested corrections for mistyped commands and so with that working I stopped investigating.

By the way, did you know you can open multiple tabs within Terminal? When I discovered that it was like the whole world changed at once.

eftychia: Me in kilt and poofy shirt, facing away, playing acoustic guitar behind head (Default)
posted by [personal profile] eftychia at 06:46pm on 2010-07-11
I don't want the same thing to start up every time I start Terminal -- I tend to use Terminal for lots of stuff at once -- but I want the ability to, from a script, pop open a new Terminal window running a specific command (which may be different in different scripts/buttons).

Fortunately, a solution does exist (*whew*), which I just posted a link to.

I knew I could open multiple tabs in the Linux equivalent; I think I'd accidentally bumped into that in Terminal as well ... I don't use that much (despite making extensive use of tabs in web browsers), because I often want to be able to look at multiple sessions simultaneously. But since you've reminded me the feature is there, I should start looking for situations where I don't need to see everything at once, so I can use tabs to save space on my screen. (I really want about six monitors, to see everything I'm working on at once, but that'd make a laptop rather unweildy.)

Links

January

SunMonTueWedThuFriSat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24
 
25
 
26
 
27
 
28
 
29
 
30
 
31