replacement of selected text not working?

ohle

Registered
Hi!

I'm completely new to Automator, having recently switched from Unix (FreeBSD) to MacOS. I wanted to create a service that would let me edit text in any text field in an external editor. I thought this should be easy with automator, and that I could just use a shell script to do it. Here is what I did:

I created a Service in Automator for selected text from any application, with the "Output replaces selected text" checkbox checked. The only object in the workflow is a shellscript that gets the text passed via stdin, using /bin/bash. Here is the code:

Code:
tempfile=$(mktemp -t macvimbuffer)
cat >$tempfile
open -n -W -a MacVim.app $tempfile
cat $tempfile
rm $tempfile

When I test the script in Automator, a MacVim window opens with the selected text displayed. I can edit it, save and quit MacVim, and Automator displays the edited text as a "result".

So I tried using the service from TextEdit, and indeed I get a MacVim window with the selected text. I can edit and save it. When I check the contents of the temporary file, it does contain the edited text. When I then quit MacVim, I go back into TextEdit, but the selected text remains unchanged.

What might be the issue here?

Thanks in advance for any useful hints,
Ohle
 
I don't see the problem. In fact, I tried your script and it works just fine for me. Hmmm.

Sorry I can't be more helpful. :\ Have you tested your service with any programs besides TextEdit?
 
Back
Top