Add OmniFocus Tasks from the Command Line

Now that I spend a lot of time at the command line, I wanted an easy way to create tasks in OmniFocus without leaving the command line. Sure, Alfred can be called up while you’re at the command line, but it’s just easier to have a shell program or function. I remembered Brett Terpstra’s oTask from a while back, but I thought it went a bit overboard. He implemented a whole system for checking syntax in Ruby and called a lot of dependencies like Appscript and as far as I can tell, it’s unnecessarily complicated. If all you want to do is create tasks from the command line using a succinct syntax, look no further than OmniFocus’ built-in transport text.

    # of "Test! @house ::misc #tom 8am #tom 8pm //notes"
    function of() {
      osascript <<EOT
      tell application "OmniFocus"
        parse tasks into default document with transport text "$@"
      end tell
    EOT
    }

Updated 2014-07-09: I changed this to use the $@ variable because that way you don’t need to quote the arguments all together.

The above shell function will take a quoted string as its parameter and parse it with the same transport text filter that OmniFocus uses in standard AppleScripts.

Feel free to fork this function or comment on it here.

Published on July 8, 2014


Related Posts