Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Last active November 23, 2020 21:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talkingmoose/4392c29f6653d33069c7a3c34cb2f858 to your computer and use it in GitHub Desktop.
Save talkingmoose/4392c29f6653d33069c7a3c34cb2f858 to your computer and use it in GitHub Desktop.
Copies titles of completed tasks in Things to current Daily Note in Bear and marks it as done. Save this AppleScript to the Scripts folder for Things at ~/Library/Scripts/Applications/Things and call it using the system-wide AppleScript menu.
(*
----------------------------------------------------------------------------------
ABOUT THIS SCRIPT
Written by:William Smith
Professional Services Engineer
Jamf
bill@talkingmoose.net
https://gist.github.com/4392c29f6653d33069c7a3c34cb2f858
Originally posted: July 16, 2018
Purpose: Copies titles of completed tasks in Things to current Daily Note
in Bear and marks it as done.
Instructions: Add this script to the computer-wide AppleScript folder:
"/Library/Scripts/Add Completed Tasks to Bear Daily Notes.scpt"
Except where otherwise noted, this work is licensed under
http://creativecommons.org/licenses/by/4.0/
"My GPS says turn left, I turn left. No questions asked. I don't want to be rude."
----------------------------------------------------------------------------------
*)
-- for consistency across scripts, using shell to return today's date
set todaysDate to do shell script "date +\"%B %-d, %Y\"" -- e.g. "February 25, 2018"
set completedToDos to {}
-- add "Completed tasks" header to today's daily note
set bearText to "## Completed tasks"
do shell script "open \"bear://x-callback-url/add-text?title=" & todaysDate & "&text=" & bearText & "\""
set completedToDos to 0
tell application "Things3"
-- get list of completed to do items from today
set todaysTodos to every to do of list "Today"
-- add each to do item to Bear Daily Notes
repeat with aToDo in todaysTodos
if completion date of aToDo exists then
set taskName to name of aToDo
set completionDate to completion date of aToDo
set completionTime to time string of completionDate
set shorterCompletionTime to (characters 1 through -7 of completionTime as string) & " " & (characters -2 through -1 of completionTime as string)
set bearText to "+ " & taskName & return & "Task marked completed at " & shorterCompletionTime as string
do shell script "open \"bear://x-callback-url/add-text?title=" & todaysDate & "&text=" & bearText & "\""
set completedToDos to completedToDos + 1
end if
end repeat
end tell
-- make note if no to do items were completed today
if completedToDos = 0 then
set bearText to "No completed tasks for today"
do shell script "open \"bear://x-callback-url/add-text?title=" & todaysDate & "&text=" & bearText & "\""
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment