Send Tasks to Focus

Posted by jochi, Last update 5 days ago

Add the selected text or entire contents of the draft to Focus app (

  • If there is no selection, each line will be added as a task in Focus.
  • Markdown headings and empty lines will be ignored.
  • Unformatted text, simpletask, and markdown list items will be added as tasks
  • Completed simpletask items will be ignored ## Supported Parameters


  • Markdown links are recognized and will be linked in Focus, e.g. Task to do
  • By default, each task will link back to the source Draft


  • Example: @est(10) will be interpreted as 10 minutes
  • Only estimates in minutes are supported at this time


  • Text following the pipe character “|” will be stored in the Notes of the Focus task


  • script

    const d = draft;
    const task_list = d.processTemplate("[[selection]]");
    const base_url = "focusapp://add";
    const source_url = d.processTemplate("[[draft_open_url]]");
    const estimate_regex = /@est\((\d+)\)/;
    var link_url;
    var tasks = task_list.split(/\n/).reverse();
    for (var task of tasks) {
      if (task.match(/(^#)|(^\s*$)|(^- \[x\])|(^- [.] $)|(.*?~~.*?~~.*?)/)) { // ignore lines that are struck out, have completed tasks, or are markdown headings or empty
      } else {
        task = task.replace(/^- (\[ ] )?(.*)/,"$2");
        var estimate = task.match(estimate_regex); // If there is an estimate assign for inclusion
        var note = task.split(/\|/)[1]; // If there is a note, assign for inclusion
        task = task.replace(/ @est\(.*?\)/, "").replace(/\|.*/, ""); // Delete estimate tag and note
        if (task.match(/\[.*?\]\(.*?\)/)) {
          link_url = getLink(task);
          task = task.replace(/\[(.*?)\]\(.*?\)/,"$1");
        } else {
          link_url = source_url;
        var cb = CallbackURL.create();
        cb.baseURL = base_url;
        cb.addParameter("title", task);
        cb.addParameter("sourceURL", link_url);
        if (estimate) { cb.addParameter("minutesEstimate", estimate[1]); }
        if (note) { cb.addParameter("note", note); }
        // open and wait for result
        var success =;
        if (!success) {
          if (cb.status == "cancel") {
          } else {
    function getLink(task) {
      return task.match(/\((.*?)\)/)[1];


  • After Success Nothing
    Notification Info
    Log Level Info
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.