content: #!/usr/bin/osascript
  
  ### General Utils
  
  on stringSplit(str, delimeter)
    -- save delimiters to restore old settings
    set oldDelimiter to AppleScript's text item delimiters
    -- set delimiters to delimiter to be used
    set AppleScript's text item delimiters to delimeter
    -- create the array
    set textList to every text item of str
    -- restore the old setting
    set AppleScript's text item delimiters to oldDelimiter
    -- convert to strings
    set stringList to {}
    repeat with textItem in textList
    copy textItem as string to end of stringList
    end repeat
    -- return the result
    return stringList
  end stringSplit
  
  on listJoin(stringList, delimeter)
    -- save delimiters to restore old settings
    set oldDelimiter to AppleScript's text item delimiters
    -- set delimiters to delimiter to be used
    set AppleScript's text item delimiters to delimeter
    -- create the string
    set str to the stringList as string
    -- restore the old setting
    set AppleScript's text item delimiters to oldDelimiter
    -- return the result
    return str
  end listJoin
  
  ### Todo Tag Utils
  
  on getTagList(todo)
    tell application "Things3"
      set tagList to tags of todo
    end tell
    return tagList
  end getTagList
  
  on setTagList(todo, tagList)
    set tagNames to listJoin(tagList, ", ")
    tell application "Things3"
      set tag names of todo to tagNames
    end tell
  end setTagList
  
  on addNowTag(todo)
    set tagList to getTagList(todo)
    set newTagNameList to {}
  
    repeat with tagTag in tagList
      set tagName to name of tagTag
      if tagName is equal to "Now" then
        return
      end if
      copy tagName to the end of newTagNameList
    end repeat
  
    copy "Now" to the end of newTagNameList
  
    setTagList(todo, newTagNameList)
  end addNowTag
  
  on removeNowTag(todo)
    if todo is null
      return
    end if
    set tagList to getTagList(todo)
    set newTagNameList to {}
    set hasNowTag to false
  
    repeat with tagTag in tagList
      set tagName to name of tagTag
      if tagName is not equal to "Now" then
        copy tagName as string to the end of newTagNameList
      else
      set hasNowTag to true
      end if
    end repeat
  
    if hasNowTag is false
      return
    end if
  
    setTagList(todo, newTagNameList)
  end removeNowTag
  
  ### Todo Misc Utils
  
  on moveToList(todo, listName)
    tell application "Things3"
      move todo to list listName
    end tell
  end moveToList
  
  on getTodoByName(name, listName)
    tell application "Things3"
    set todo to to do named name of list listName
    end tell
  
    return todo
  end getTodoByName
  
  on getTodos(listName)
    set nowTodoName to ""
  
    tell application "Things3"
    set todos to to dos of list listName
    end tell
  
    set todoCount to count of todos
    set nowTodo to null
    set incompleteTodos to {}
    set completedTodos to {}
  
    repeat with n from 1 to todoCount
      set todo to item n of todos
      tell application "Things3"
      set todoCompleted to status of todo is not open
      end tell
  
      if todoCompleted is not true then
        tell application "Things3"
        set tagList to tags of todo
        end tell
        set hasNowTag to false
  
        repeat with tagTag in tagList
          set tagName to name of tagTag
  
          if tagName is equal to "Now" then
            # now todos
            if todoCompleted or listName is not equal to "Today" then
              removeNowTag(todo)
            else
              if nowTodo is not null
                removeNowTag(todo)
              else
                set nowTodo to todo
              end if
            end if
          end if
        end repeat
      end if
      if todo is not equal to nowTodo
        # not now todo
        if todoCompleted then
          copy todo to the end of completedTodos
        else
          copy todo to the end of incompleteTodos
        end if
      end if
    end repeat
  
    return { nowTodo, incompleteTodos, completedTodos }
  end getTodos
  
  
  on run argv
    set argCount to count of argv
  
    if argCount is greater than 0
      set f to POSIX file "/Users/tjmehta/Developer/scratch/log.log"
      write item 1 of argv & " " as string to f starting at eof
      if argCount is greater than 1
        write item 2 of argv & "\n" as string to f starting at eof
      end if
      if argCount is greater than 2
        write item 3 of argv & "\n" as string to f starting at eof
      end if
      if argCount is greater than 3
        write item 4 of argv & "\n" as string to f starting at eof
      end if
  
      # OPERATIONS: TODO
      if item 1 of argv is "complete"
        set todoName to item 2 of argv
        set todo to getTodoByName(todoName, item 3 of argv)
  
        tell application "Things3"
        set status of todo to completed
        end tell
        removeNowTag(todo)
  
        return
      end if
      if item 1 of argv is "delete"
        set todoName to item 2 of argv
        set todo to getTodoByName(todoName, item 3 of argv)
  
        removeNowTag(todo)
        tell application "Things3"
          delete todo
        end tell
  
        return
      end if
      if item 1 of argv is "add-now-tag"
        set todoName to item 2 of argv
        set todo to getTodoByName(todoName, item 3 of argv)
        set todoLists to getTodos("Today")
        set nowTodo to item 1 of todoLists
  
        if nowTodo is not null and name of nowTodo is equal to name of todo
          return
        end if
  
        removeNowTag(nowTodo)
        if item 3 of argv is not equal to "Today"
          moveToList(todo, "Today")
        end
        addNowTag(todo)
        return
      end if
      if item 1 of argv is "remove-now-tag"
        set todoName to item 2 of argv
        set todo to getTodoByName(todoName, item 3 of argv)
  
        removeNowTag(todo)
        return
      end if
      if item 1 of argv is "move-to"
        set todoName to item 2 of argv
        set todo to getTodoByName(todoName, item 3 of argv)
  
        if item 3 of argv is not equal to item 4 of argv
          moveToList(todo, item 4 of argv)
        end if
        return
      end if
  
      # COMMANDS: APP
      if item 1 of argv is "launch"
        tell application "Things3"
          activate
        end tell
        return
      end if
      if item 1 of argv is "new-todo"
        tell application "Things3"
          show quick entry panel
        end tell
        return
      end if
      if item 1 of argv is "log-completed"
        tell application "Things3"
          log completed now
        end tell
        return
      end if
      if item 1 of argv is "empty-trash"
        tell application "Things3"
          empty trash
        end tell
        return
      end if
    end if
  
    ######
    ### DISPLAY
    ######
    set filepath to path to me
    set filepathList to stringSplit(filepath as string, ":")
    set arg0 to "/" & listJoin(filepathList's (items 2 thru -1), "/")
    set logs to ""
  
    if argCount is greater than 0
      set arg1 to item 1 of argv
    else
      set arg1 to ""
    end if
  
    if application "Things3" is not running
      # THINGS IS NOT RUNNING
      set logs to logs & "‚òë" & "\n"
      set logs to logs & "---" & "\n"
      set logs to logs & "Things is not running" & "\n"
      set logs to logs & "Open Things | shell='" & arg0 & "' param1=launch terminal=false refresh=true"
    else
      # THINGS IS RUNNING
      set todoLists to getTodos("Today")
      set nowTodo to item 1 of todoLists
      set incompleteTodos to item 2 of todoLists
      set completedTodos to item 3 of todoLists
      set inboxTodoLists to getTodos("Inbox")
      set inboxTodos to item 2 of inboxTodoLists
      set inboxCompletedTodos to item 3 of inboxTodoLists
  
      ### MENUBAR ###
  
      if nowTodo is null
        set logs to logs & "‚òë" & "\n"
      else
        set logs to logs & "‚òê " & name of nowTodo & "\n"
      end if
  
      ### DROPDOWN ###
  
      set logs to logs & "---" & "\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JyGPrEfLZpWCCd0Ud+BorDiojie/UWUl4XUo9H+pP+eX8k0sTAZnIi39+U8hLXdOC8rsx0JNzZhwsRKxbip3UIhlpL8T+hnfp9/99n4A+FMeksKA2hgQAAAABJRU5ErkJggg=="
      set somedayIcon to "iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAFBlWElmTU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAFqADAAQAAAABAAAAFgAAAAAO/B1EAAAB2UlEQVQ4Ee1TvU7cQBCe8a4tMAdpkNIgJERPRRmJghZqeroUdIgHSCp+SlpegI6KBomCBikFBW+AaJAQugvB3OHdnczYHp99d0hpKCIx0t387jfjb3YBPuW/ZQCbk1+e7a3GCZ1QoCQQVSkpUbtZrTZCHBvIc3+xtnG0o1Grhmg0bmm201lxXoBaPRtl2mSYtwah23txjSJoAUdogjER5wMQ6aQKoICS18alLs80YWEEOES/ut3sZ8BgGfufJYktENJt80Br4m+b+3dX57s3Bs18HnxRFxmej0BULUQReV6EBiKmYsqZK/VFt4CLBOHh3Jd02btyZOc9vGaDwF79DTaObGd6irdQ0pQkBp76v7f4/GmBwX9CWEu4OHMMKguUmfr9/PEtuMX0vpemX3upT2emudmBLFdq5DcYOPBE7y+v1YEdEg4Q56yxP14WZp/hAdFAxgC47oubMzxhoEnWJCrqa4bCLSQsM4nZ1rshafmiUFBcR4cdKmuc4yLBB5BRZT0RQi58i93CqRyNtQeesDzBxGotAq5ohS1dBYnjXKPdsM5JvpSxiYnfn60eSQ1a1Opo4qhdanl5ozIOTHT8/Cf7Hjy/vtHqCb68Ou/DXfYG1xPSn6EPZOAvfu2n8pRVKagAAAAASUVORK5CYII="
      set anytimeIcon to "iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABGdBTUEAALGPC/xhBQAAAFBlWElmTU0AKgAAAAgAAg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      if nowTodo is not null
        set todoName to name of nowTodo
        set logs to logs & "‚òê " & todoName & " #Now | shell='" & arg0 & "' param1=remove-now-tag param2='" & todoName & "' param3=Today terminal=false refresh=true" & "\n"
        set logs to logs & "-- Complete | image='" & completeIcon & "' shell='" & arg0 & "' param1=complete param2='" & todoName & "' param3=Today terminal=false refresh=true" & "\n"
      end if
  
      if count of incompleteTodos is greater than 0
        set logs to logs & "Today" & "\n"
        repeat with todo in incompleteTodos
          set todoName to name of todo
          set logs to logs & "‚òê " & todoName & "| shell='" & arg0 & "' param1=add-now-tag param2='" & todoName & "' param3=Today terminal=false refresh=true" & "\n"
          set logs to logs & "--  Complete | image='" & completeIcon & "' shell='" & arg0 & "' param1=complete param2='" & todoName & "' param3=Today terminal=false refresh=true" & "\n"
          set logs to logs & "--  Inbox | image='"    & inboxIcon    & "' shell='" & arg0 & "' param1=move-to param2='"  & todoName & "' param3=Today param4=Inbox terminal=false refresh=true" & "\n"
          set logs to logs & "--  Upcoming | image='" & upcomingIcon & "' shell='" & arg0 & "' param1=move-to param2='"  & todoName & "' param3=Today param4=Upcoming terminal=false refresh=true" & "\n"
          set logs to logs & "--  Anytime | image='"  & anytimeIcon  & "' shell='" & arg0 & "' param1=move-to param2='"  & todoName & "' param3=Today param4=Anytime terminal=false refresh=true" & "\n"
          set logs to logs & "--  Someday | image='"  & somedayIcon  & "' shell='" & arg0 & "' param1=move-to param2='"  & todoName & "' param3=Today param4=Someday terminal=false refresh=true" & "\n"
          set logs to logs & "--  Delete | image='"   & deleteIcon   & "' shell='" & arg0 & "' param1=delete param2='"   & todoName & "' param3=Today terminal=false refresh=true" & "\n"
          -- set logs to logs & "-- Anytime | shell='" & arg0 & "' param1=move-to param2='" & todoName & "' param3=Today param4=Someday terminal=false refresh=true" & "\n"
          -- set logs to logs & "-- Someday | shell='" & arg0 & "' param1=move-to param2='" & todoName & "' param3=Today param4=Someday terminal=false refresh=true" & "\n"
        end repeat
      end if
  
      if count of inboxTodos is greater than 0
        set logs to logs & "Inbox" & "\n"
        repeat with todo in inboxTodos
          set todoName to name of todo
          set logs to logs & "‚òê " & todoName & "| shell='" & arg0 & "' param1=add-now-tag param2='" & todoName & "' param3=Inbox terminal=false refresh=true" & "\n"
          set logs to logs & "--  Today | image='"    & todayIcon    & "' shell='" & arg0 & "' param1=move-to param2='"  & todoName & "' param3=Inbox param4=Today terminal=false refresh=true" & "\n"
          set logs to logs & "--  Upcoming | image='" & upcomingIcon & "' shell='" & arg0 & "' param1=move-to param2='"  & todoName & "' param3=Inbox param4=Upcoming terminal=false refresh=true" & "\n"
          set logs to logs & "--  Anytime | image='"  & anytimeIcon  & "' shell='" & arg0 & "' param1=move-to param2='"  & todoName & "' param3=Inbox param4=Anytime terminal=false refresh=true" & "\n"
          set logs to logs & "--  Someday | image='"  & somedayIcon  & "' shell='" & arg0 & "' param1=move-to param2='"  & todoName & "' param3=Inbox param4=Someday terminal=false refresh=true" & "\n"
          set logs to logs & "--  Delete | image='"   & deleteIcon   & "' shell='" & arg0 & "' param1=delete param2='"   & todoName & "' param3=Inbox terminal=false refresh=true" & "\n"
          set logs to logs & "--  Complete | image='" & completeIcon & "' shell='" & arg0 & "' param1=complete param2='" & todoName & "' param3=Inbox terminal=false refresh=true" & "\n"
        end repeat
      end if
  
      if count of completedTodos is greater than 0 or count of inboxCompletedTodos is greater than 0
        set logs to logs & "Completed" & "\n"
      end if
      if count of completedTodos is greater than 0
        repeat with todo in completedTodos
          set todoName to name of todo
          set logs to logs & "‚òë " & todoName & " | color=#666666 shell='" & arg0 & " terminal=false refresh=true'\n"
          set logs to logs & "-- Delete | shell='" & arg0 & "' param1=delete param2='" & todoName & "' param3=Today terminal=false refresh=true" & "\n"
        end repeat
      end if
      if count of inboxCompletedTodos is greater than 0
        repeat with todo in inboxCompletedTodos
          set todoName to name of todo
          set logs to logs & "‚òë " & todoName & " | color=#666666 shell='" & arg0 & " terminal=false refresh=true'\n"
          set logs to logs & "-- Delete | shell='" & arg0 & "' param1=delete param2='" & todoName & "' param3=Inbox terminal=false refresh=true" & "\n"
        end repeat
      end if
      if count of completedTodos is greater than 0 or count of inboxCompletedTodos is greater than 0
        set logs to logs & "Log Completed | color=#333333 shell='" & arg0 & "' param1=log-completed terminal=false refresh=true" & "\n"
      end if
  
      set logs to logs & "---" & "\n"
  
      set logs to logs & "New Todo | shell='" & arg0 & "' param1=new-todo terminal=false refresh=true" & "\n"
      set logs to logs & "Open Things | shell='" & arg0 & "' param1=launch terminal=false"
    end if
  
    ### PRINT STDOUT ###
    copy logs to stdout
  end run
  