On 2011-01-03 16:39, Ian Greig wrote:
The "mate" command question
Another way devised by Tinderbox users involves using a macro to call the
"mate" command. That brings me full circle. I do not seem to be able to make
this work, even by invoking the command line directly in Terminal. I would
like some help with this please.
I know nothing about Tinderbox, but that's not going to keep me from
jumping in here...
The very first thing you have to do is to install the 'mate' command.
You say that you "do not seem to be able to make this work, even by
invoking the command line directly in Terminal." That suggests to me
that this first step has not been taken. Refer to the blog posting at
details, but you'll need to execute these commands:
ln -s /Applications/TextMate.app/Contents/Resources/mate ~/bin/mate
There are other niceties too, but that's the basics. Now type
'~/bin/mate /tmp/test' at the Terminal command line. Does it open a new
Textmate window editing the file /tmp/test? If so, congratulations!
You're halfway there.
In general, there are two ways to invoke 'mate' as an external editor.
The first is as described above, by having Tinderbox (or whatever other
app) write a temporary file and calling 'mate' to edit it. You'll
probably want to give 'mate' the '--wait' option. Without that option,
the Textmate window is opened and control immediately returns to the
caller. Unfortunately, that's the end of the transaction. There's no
way for the calling program to know when you're done editing. The
'--wait' option tells 'mate' not to return control to the caller until
you've closed the window. This will signal the calling program that
it's time to read the temp file back in to get your changes.
To do it this way you'll need to write a macro in Tinderbox that does this:
save to /tmp/filename
mate --wait /tmp/filename
Since I don't know anything about Tinderbox I'm afraid I can't be any
The second way to use 'mate' as an external editor is similar, but
instead of writing to a temporary file you feed the file to mate on its
standard input and read the changes back from its standard output.
"Standard input" (stdin) and "standard output" (stdout) are generic
terms meaning "what the program reads in from the Terminal" and "what it
writes back to the Terminal". Only, "Terminal" doesn't have to
be Terminal.app, it can be any other program. If you run the command 'ls
| less' at the Terminal prompt you're using the pipe ("|") character to
send the standard output of the 'ls' command to the standard input of
the 'less' command, instead of sending the output of 'ls' directly back
to the Terminal window. Piping stdout from one program to the stdin of
another is the fundamental basis of almost all Unix command-line
programing. You can chain any number of commands together this way. Try
typing: 'echo "hello, world" | mate --wait | less' to see what I mean.
To apply this to Tinderbox you'll need to tell it to write to mate's
standard input and read from mate's standard output. Again, I don't know
what the syntax would be as a Tinderbox macro, but conceptually
write file to mate's stdin
read file from mate's stdout
I can't give you cookie-cutter directions, but hopefully this gives you
enough understanding of what's going on to figure the rest out yourself.
Sr. Software Engineer
+1 734 821 1461