Question

TextWranger comes with it's command-line tool, "edit", which allows me to open a file for editing on the command-line. The problem is, the "edit" program ends (returns control to the calling program) as soon as it sends the command to TextWrangler to open a file.

This can create a problem if I want to use TextWrangler as my editor-of-choice for a script designed with tools like "vi" in mind, which cause the shell that causes them to wait until the editing is complete and the file is closed.

Now, in theory, I know a way I can get around this. I can write a wrapper script which does three things: (1) calls "edit" with whichever file I am wishing to edit (2) continues it's run, checking over and over (no more frequently than every second - but could by preference be adjusted to do this less frequently) to see whether TextWrangler still has the file I asked it to edit open and (3) ending it's execution only once TextWrangler no longer has the file open.

Of course, this is something that I currently only can do in theory -- to bring the theory to actual practice there is one more thing I would need to know --- and that is, is there a way for a script to check from the command-line what files TextWrangler currently has open -- or better yet, whether or not it still has open the specific file that I am concerned with?

Was it helpful?

Solution

Use --wait for both twdiff and edit. I use this extensively with vim, as well as svn/git: without those flags, the temp files are immediately removed and diffing or editing them causes errors as the original file can't be found.

It also lets you cycle through multiple files and the next file won't be opened until the last one has been closed.

See twdiff -? or edit -? for more details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top