Last active
February 24, 2019 13:56
-
-
Save talkingmoose/1faa0d675f5c96529973b7b9e6de3237 to your computer and use it in GitHub Desktop.
Copies completed tasks in Things Logbook to Daily Note in Bear for a specified date. Useful after forgetting to copy tasks the day they were completed. Save this AppleScript to the Scripts folder for Bear at ~/Library/Scripts/Applications/Bear and call it using the system-wide AppleScript menu.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* | |
| ---------------------------------------------------------------------------------- | |
| ABOUT THIS SCRIPT | |
| Written by:William Smith | |
| Professional Services Engineer | |
| Jamf | |
| [email protected] | |
| https://gist.github.com/1faa0d675f5c96529973b7b9e6de3237 | |
| Originally posted: August 5, 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/ | |
| "So much time and so little to do. Wait a minute. Strike that. Reverse it." | |
| ---------------------------------------------------------------------------------- | |
| *) | |
| -- 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" | |
| -- request date | |
| set targetDate to text returned of (display dialog "Choose a date..." default answer todaysDate buttons {"Cancel", "OK"} default button {"OK"} with title "Add Past Completed Tasks to Bear Daily Notes") | |
| set startDate to date targetDate | |
| set endDate to startDate + 86400 | |
| 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=" & targetDate & "&text=" & bearText & "\"" | |
| set completedToDos to 0 | |
| tell application "Things3" | |
| -- get list of completed to do items from today | |
| set targetDateTodos to every to do of list "Logbook" whose completion date is greater than startDate and completion date is less than endDate | |
| end tell | |
| set targetDateTodos to reverse of targetDateTodos | |
| tell application "Things3" | |
| -- add each to do item to Bear Daily Notes | |
| repeat with aToDo in targetDateTodos | |
| 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=" & targetDate & "&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=" & targetDate & "&text=" & bearText & "\"" | |
| end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment