I wonder whether I can invoke a program from an action. An example of the workflow I have in my mind is as follows: Suppose that a shell command is written as a link in the note field of an action or a project (e.g., /Applications/Emacs.app ~/work/foo/main.tex). By clicking the link, OmniFocus invokes emacs with the argument ~/work/foo/main.tex. I consider using this to invoking all the programs to get the action done (e.g., invoking an editor with a LaTeX manuscript and invoking a viewer with PDFs needed to get the writing done.)
Since I’m not familiar with AppleScript, please let me know if this is easy to do with a script, thanks!
You can drag a programme icon into the notes field to easily launch a programme or drag a PDF, or other file into it as well.
To execute a particular command, not sure but probably in AppleScript., I would think it may be better to use something like keyboard maestro to set up a workflow which could be adapted to be used over again by using variables to execute a specific command on a file or at the terminal.
After one year, maybe I found a (partial) solution to do what I want to do by Automator. I created a service (whose name is, say, “Do”) using Automator that (1) receives a text from OmniFocus and (2) executes the following shell script written in Perl:
while (<>) {
/\((exec (.*))\)/;
system $1;
}
Then, in OmniFocus, I make an item whose name is something like following:
Write a paper (exec /Applications/Emacs.app ~/work/foo/main.tex)
When I want to do this action, right click on the item, go to “service”, and select “Do”. Then, Automator executes the command “/Applications/Emacs.app ~/work/foo/main.tex”.
One thing about security: I think this method is inherently insecure; it executes any code written on the item name.