Git Product home page Git Product logo

things.sh's Introduction

Things 3 CLI

Overview

Simple read-only comand-line interface to your Things 3 database (incl. CSV export). Since Things uses a SQLite database (which should come pre-installed on your Mac) we can simply query it straight from the command line. We only do read operations since we don't want to mess up your data.

Note that I've migrated this bash based version to a python based fork.

Codacy Badge Build Status download

Installation

You can use brew to install and later update the script:

  • Prepare: brew tap AlexanderWillner/tap
  • Install: brew install things.sh
  • Upgrade: brew upgrade
  • Bash autocompletion: brew install bash-completion. Then add to ~/.bashrc:
    if [ -f $(brew --prefix)/etc/bash_completion ]; then
      . $(brew --prefix)/etc/bash_completion
    fi
  • Zsh autocompletion: copy the file things.zshcompletion.sh to a location you like, and add source /path/to/things.zshcompletion.sh to your ~/.zshrc

To uninstall just write brew uninstall things.sh.

Example Graphs

These graphs have been generated based on the CSV export. For example: things.sh -r '-14 days' statcsv > lastTwoWeeks.csv && open lastTwoWeeks.csv (and then generating a Stacked Column graph).

Tasks in the last 14 days

Tasks in the last year

Tasks since using Things

Instructions

Note that you could override the location of the database used by setting the THINGSDB environment variable. For usage information, run the script with no arguments or with "help":

$ things.sh --limitBy 5 help
usage: things.sh <OPTIONS> [COMMAND]

OPTIONS:
  -l|--limitBy <number>    Limit output by <number> of results
  -w|--waitingTag <tag>    Set waiting/filter tag to <tag>
  -o|--orderBy <column>    Sort output by <column> (e.g. 'userModificationDate' or 'creationDate')
  -s|--string <string>     String <string> to search for
  -r|--range <string>      Limit CSV statistic export by <string>
  -e|--event <filename>    Event: <filename> that contains a list of tasks
  -t|--start <date>        Event: starts at <date>
  -d|--duration <days>     Event: ends after <days>

COMMANDS:
  inbox                    Shows 5 inbox tasks ordered by creationDate
  today                    Shows 5 todays tasks ordered by index
  upcoming                 Shows 5 upcoming tasks ordered by date
  next                     Shows 5 next tasks ordered by creationDate
  someday                  Shows 5 someday tasks ordered by creationDate
  completed                Shows 5 completed tasks ordered by creationDate
  cancelled                Shows 5 cancelled tasks ordered by cancel date
  trashed                  Shows 5 trashed tasks ordered by creationDate
  feedback                 Opens the feedback web page to request and propose changes
  all                      Shows 5 tasks ordered by creationDate
  csv                      Exports all tasks as semicolon seperated values incl. notes and Excel friendly
  due                      Shows 5 tasks ordered by due date
  headings                 Shows 5 headings ordered by creationDate
  mostClosed               Shows 5 days on which most tasks were closed
  mostCancelled            Shows 5 days on which most tasks were cancelled
  mostTrashed              Shows 5 days on which most tasks were trashed
  mostCreated              Shows 5 days on which most tasks were created
  mostTasks                Shows 5 projects that have most tasks
  mostCharacters           Shows 5 tasks that have most characters
  nextish                  Shows 5 nextish tasks ordered by creationDate
  old                      Shows 5 old tasks ordered by creationDate
  projects                 Shows 5 projects ordered by creationDate
  repeating                Shows 5 repeating tasks ordered by creationDate
  schedule                 Schedule an event by creating a number of related tasks
  search                   Searches for a specific task
  stat                     Provides a number of statistics about all tasks
  statcsv                  Exports some statistics as semicolon separated values for -1 year
  subtasks                 Shows 5 subtasks ordered by creationDate
  tag                      Shows 5 tasks with the tag "Waiting for" ordered by "creationDate"
  tags                     Shows 5 tags ordered by their usage
  waiting                  Shows 5 tasks with the tag "Waiting for" ordered by "creationDate"

Examples

CSV export and open with Excel

things.sh csv > Things3Export.csv && open Things3Export.csv

Note that this command generates a standards compliant file. If you have problems opening it using Microsoft Excel, you might want to change some parameters. E.g., SEP=";" ENCODING="WINDOWS-1252//TRANSLIT" ./things.sh csv > Things3Export.csv.

Statistics

$ things.sh stat
Inbox     : 0
Today     : 7
Upcoming  : 156
Next      : 15
Someday   : 822

Completed : 11976
Cancelled : 9250
Trashed   : 545

Tasks     : 968
Subtasks  : 56
Waiting   : 111
Projects  : 89
Repeating : 89
Nextish   : 146
Headings  : 53

Oldest    : 2010-09-28|XXX|XXX
Farest    : 2021-01-04|XXX|XXX
Longest   : 167|XXXXXXXXXXXXXX
Largest   : 128|XXXXXXXXXXXXXX

Created   : 147|2017-07-04
Closed    : 124|2017-12-30
Cancelled : 324|2017-12-30
Trashed   : 109|2017-08-02
Days/Task : 41.0

Create Scheduled Event

Things.sh Scheduler

In case you have regularly to create projects based on a template (e.g., a business trip or family vacation), this can be automated using the following command:

$ things.sh --start 2018-03-20 --days 7 --event resources/exampleEvent.thingslist schedule

Note that you might have to Enable Things URLs in the Things preferences first.

Other Information

Things URL Helper

Things3 URL Helper

Since Version 3.4 Things.app has its own URL Scheme. It replaces the application ThingsURLHelper.app that you can still find in the folder resources. By using most of the commands (e.g., things.sh csv) you can identify the according URL of each task and open it within any macOS application, such as spotlight. Above an example using a local web page. You can click on the links in Terminal.app by using CMD+DoupleClick.

Markdown Clipboard to Things Workflow

Demo Markdown Clipbaord to Things3

You can use the service/workflow in the folder resources to automatically convert MarkDown todos into Things 3 tasks. Above an example using Bear.app. To install you have two options:

  • Alfred Workflow: Download and double click on the workflow file
  • macOS Service: Download, unzip and copy the workflow file to ~/Library/Services (you may need to enable the service under System Preferences > Keyboard > Shortcuts > Services > General > Markdown Clipboard to Things)

Count Minutes Planned Today

It has some benefits to use time estimates in your to-do list. In case you're using tags like XXmin (XX = number in minutes), then there is one script in this repository that can calculate the total minutes of planned to-dos in your Today view. To install, download the service, unzip it and copy the workflow file to ~/Library/Services (you may need to enable the service under System Preferences > Keyboard > Shortcuts > Services > General > Markdown Clipboard to Things).

Minutes Planned Today in Things3

CREDITS

things.sh's People

Contributors

alexanderwillner avatar avdgaag avatar codacy-badger avatar lenis2000 avatar mltucker avatar zeddee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

things.sh's Issues

HowTo excel chart

Hi Alexander,
thanks for your great work, exactly what I'm looking for in order to create a statistic for my GTD behavior. But how do you produce that example chart with the title "Things 3 Tasks (14 days)", the file in img/example3.jpg ? With things.sh csh I produce the csv file, import it into excel and create a pivot table from the column creation date but the result is different :-(
Can you please explain your steps in Excel (or Numbers).

Thanks in advance
Dominik

Multi-line notes concatenate into one line in CSV export

The CSV export concatenates multi-line notes fields into one line by replacing CR (13) and LF (10) characters with a comma. This makes the notes fields unreadable in the CSV export.

Furthermore, you cannot undo the damage using search and replace, because commas appear frequently in normal text.

The CSV format is capable of handling multi-line values. They just need to be enclosed in double quotes as I understand. Furthermore, Excel will import them successfully, and display them as a multi-line cell. This is the desired behaviour, in my view.

Years ago, there was a Things 2 export AppleScript floating around, which isn't really usable now for several reasons - but one thing it did get right is that it preserved multi-line notes in CSV correctly. And these were handled by Excel without issue - each multi-line notes field appeared in a single cell in Excel containing the notes text with line breaks.

In my opinion, the CSV export should follow the principle of least surprise. It should preserve users' data wherever possible, without mangling or corrupting it. That includes preserving line breaks in the notes fields.

When exported as CSV, tasks in a heading have no properties

Great project btw, however, I have an issue with tasks in headings.

I have tasks that are in an area, in a project, and in a heading.

Example from interface:
screen shot 2018-03-14 at 21 18 23

When exporting to csv, these tasks have no useful properties that allow them to be placed in the structure. The task in the csv is of type 0. The, area, project, and subtask, are all blank. This makes it indistinguishable from a task in the inbox.

ical integration

Hello -

Have you thought about outputing an ical file so it can be subscribed to? This would be useful for showing (and linking to) deadlines and schedules.

Happy to help with this - would be good if there was a way to output by 'area'.

Could be something like this:

things.sh ical --area "Work" > work.ical

If you run this as a cron job and output to a dropbox location, you can subscribe to the ical.

query for all tasks created today

Hi,
I try to create a query (for the very beginning with my DB tool DBVisualizer) in order to count the tasks created today.
Something like
select * from TMTask where creationDate == date('now');
As I saw, column TMTask.creationDate is of type REAL and sqlite function date(...) can convert dates, but how I can combine both in order to archive my goal ?

After I got the query working, I hopefully can setup a plugin for using it together with the things.sh....

Kind regards
Dominik

things.sh with Things 3 Beta

Is it possible to tell things.sh where the Things database is? I'm using Things 3 beta so the location of the database differs slightly from the standard installation.

(Things v 3.17.4) DB Location changed, Error in prepare

Hi,
the new release of Things breaks the script in 2 ways:

1 DB location changed

Old: "/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac/Things Database.thingsdatabase/main.sqli"

New: "/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac/**ThingsData-XXXXX**/Things Database.thingsdatabase/main.sqli"

2 DB structure seemingly changed, i get the following error:

Error: in prepare, no such column:
TASK.dueDate
SELECT date(TASK.dueDate,"unixepoc..

URIs of Subtasks

Hi there,

CSVs generated appear to give incorrect URIs in the case of subtasks – these begin thingstodo:// rather than things:/// and do not succeed in linking to the task in question.

Am I doing something wrong, or is this an issue?

Thanks in advance, and very grateful for this utility!

Displaying tags along with task titles

I am using this script to log my list of completed tasks every day - I made a "logbook" plugin to pull up tasks whose stop date is today, by modifying the inbox plugin.

I'd love for this to also show me the tags of the tasks - I poked into the database and it looks like I'll have to pull this up by passing the task id into the tags table - unfortunately, I don't know how to do that. I went through tags.sh but I am still unsure.

If it is something relatively straightforward, could you please point me in the right direction?

I'm barely literate with bash and SQL - sorry for the trouble and thanks for taking a look!

iCal Feed: Based on Start Dates + Projects / Area Reference

Hi,

I haven't been here in a while, but I have to say the iCal feed is wonderful! 🎉

I've done a quick hack to use Start Dates instead of Due Dates for my Calendar feed. This way I can see all my tasks for each day coming up. I also added some data to the feed to include the Project or Area next to the task name for reference.

I'd love to contribute and create options for this in the repo, but not sure how exactly to do that yet within the project structure you currently have.

Thanks!

CSV export should default to UTF-8

The documentation says that by default, CSV export generates a file "that is readable by Microsoft Excel in Europe, i.e., the default encoding is WINDOWS-1252 and the separator is ;".

I understand this is only a default, and it can be overridden using environment variables.

However, I suggest that the default should be changed to UTF-8 and the more standard comma-separated values, for the following reasons:

  • Current versions of Excel have no issues importing UTF-8 / comma-separated - you just have to use File > Import. When prompted for an encoding, select "Unicode (UTF-8)" from the list, and for Delimiters select "Comma". This works for me on Microsoft Excel for Mac Version 16
  • Not everyone is using Microsoft Excel
  • Not everyone is in Europe
  • Not every Excel user in Europe is using Windows (especially not Things users!), hence WINDOWS-1252 is often not the default encoding anyway

The funny thing is, I am in Europe and I am using Excel. But the default encoding still corrupts my data. Why? Because I use lots Unicode characters in my task notes like bullets, ticks, crosses, arrows, currency signs, emoji, foreign words, special characters, etc.

Remember Things is a Unicode app, and its SQLite database uses UTF-8.

The CSV export function should follow the principle of least surprise, and preserve users' Unicode notes data in its default setting. It should not corrupt or mangle their data by default.

csv export

Great tool - exactly what I have been looking for.

Not sure if I am using the CSV export correctly. When opened, the type 0 tasks appear to only be able to to have one of 'Project', 'Area' or 'Heading' populated. It seems to choose the lowest level available where present. Is this an error or am I simply not using the output correctly?

Many thanks

CSV Formatting Error

I'm having trouble getting the CSV export to work properly. I assume that exporting all notes is breaking the behaviour because it also dumps the xml tags that wrap the note from the database, therefore also including the double quotes from <note xml:space="preserve"> and any other tags included within the note. Is there a way to sanitise the output by stripping tags?

I realise that, perhaps, makes this less useful but if it is the cause of csv formatting errors then it would then display properly.

Repeating tasks handled incorrectly in CSV export

Hi, it seems that the CSV export does not handle repeating tasks correctly.

I became suspicious when I noticed that my Things DB has 52 repeating tasks and the CSV export only has 11 rows where Recurring=TRUE. Those 11 appear to be repeating tasks which all have zero completed instances with the same title.

If a repeating task has one or more completed instances with the same title, then weird behaviour occurs. For example: consider a repeating task with five completed instances, all having with the same title and same tag "next".

  • Expected behaviour: the CSV contains 6 rows relating to this task, one for the repeating task itself, and five for the completed instances - all with same tag "next"
  • Actual behaviour: The CSV contains only 1 row relating to this task, with Recurring=FALSE. The completion date matches only the most recent completed instance. The tag field has the value "next,next,next,next,next,next".

The number of duplicated tag names in the tag field matches the expected (but not actual) number of rows in the CSV.

Completed instances seem to work OK only if their titles have been edited (so they're different from the parent task), but not when they share the same title as their parent task.

Update Tap?

After the recent fix for the URIs of subtasks, I have attempted to update via brew twice, and I believe this has not been updated to reflect the fix? Thanks in advance.

schedule.sh broken with python3

The schedule.sh plugin won't run with python3. I've changed my local copy to correct the issue.
current
title="$(python -c 'import urllib, sys; print urllib.quote(sys.argv[1])' "${array[3]}")"
changed to
title="$(python -c 'import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))' "${array[3]}")"

Things.sqlite3 move in Things 3.12.6

Cultured Code moved the Things db in 3.12.6 to ~/Library/Group Containers. Subsequently, things.sh fails locating the file:

$ things.sh today
Error: file is not a database
ERROR: line 1 - command 'eval "${!method}"' exited with status: 26.
ERROR: In ::queryToday::invokePlugin::parse::main::main called at line 48.
DEBUG: From function ::queryToday::invokePlugin::parse::main::main (line 48).

replacing
readonly DEFAULT_DB=~/Library/Containers/com.culturedcode.ThingsMac/Data/Library/Application\ Support/Cultured\ Code/Things/Things.sqlite3
with
readonly DEFAULT_DB="/Library/Group Containers/JLMPQHK86H.com.culturedcode.ThingsMac/Things.sqlite3"
restored access for me, though I don't know if the JLMPQHK86H part is unique per user...

Area and Project missing from many rows in csv

I exported on my MacBook Pro running OS12.3 Monteray using the command in your readme:
things.sh csv > Things3Export.csv && open Things3Export.csv

It worked perfectly, except a large percentage of the rows have empty Area and Project fields. This makes it impossible for me to import them into Evernote directly into the "notebooks" I want to transfer to.

Is there a modified command that would force them to appear?

Also, how can I export omitting the completed and duplicate tasks?

Thanks very much for making this possible!!

Manny

Checklist items are indistinguishable from parent tasks in CSV export

The CSV export shows checklist items looking almost identical to their parent tasks. This makes it extremely difficult to distinguish checklist items (which are like mini-tasks inside a task) from actual tasks.

This means you cannot, for example, filter out checklist items to see only tasks in Excel, or vice versa.

Checklist items have the same Title and URI as their parent task in the CSV. The Subtask column is always empty, regardless whether it's a checklist item or task. Checklist items do not have tags - but neither do some tasks, so this isn't a reliable way to distinguish them.

The only difference I can see is this:

  • in a task, the Notes field contains the task's notes
  • in a checklist item, the Notes field contains the name of the checklist item

However the notes field and checklist item names are both free text fields in Things.app. This means you cannot distinguish tasks from checklist items in the CSV, unless you remember what you wrote in those fields, which is different for each task and does not scale.

Ideally, checklist items would not only be distinguishable, but also appear directly underneath the task they relate to in the CSV (although that's probably harder to implement).

An alternative would be to list all checklist items for a given task in a single multi-line cell, so a task and all its checklist items have only one row in the CSV.

Tasks with empty title are not exported

Thank you for this awesome application. I have a couple of tasks which have notes but no titles. All except for one seem to be ignored when exporting the Things database via things.sh csv > Things3Export.csv && open Things3Export.csv. It would be great if the export would contain all tasks - regardless whether they have a title or not.

Tap out of date - brew installs version 2.3

It looks like the tap hasn’t been updated in a while and is still set to version 2.3. It also looks like there hasn’t been a “release” in a while (since 2.5). Is brew no longer the best way to install things.sh? I tried cloning the repository and using make install, but that doesn’t take care of the plugins (and makes me wonder if other steps might be missed going that way).

Get all tasks with a specific tag

It would be great to search for tasks with a specific tag (not just "Waiting For"). In my use case this would be useful to extract tasks which I've marked "important" and want to do this week

Identifying tasks in trash in Excel output

I have exported my things data t excel, but I cant see how to identify tasks that are in the trash, they appear in the list with all others and there doesn't appear to be a field that identifies them as trashed.

Export appropriate date

Hello Alex & thank you! Your code works splendidly.

For items that are ordered by <date>, would it be possible to export the date as well?

For instance, with '$ things.sh completed' command, having the ability to export the 'creationDate' and/or** 'Completion Date'** alongside would be great for logging completed tasks.

Potentially many others find this information very useful. Thanks for considering Alex!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.