A smart merge utility for todo.txt files.
Better cache dir initialization in script
Makes the script work with both tempname and mktemp; switches to fsnotify
Adds -1 (no-daemon) mode & generifies file suffix (although, _a_ suffix is still required


browse log




A smart merge utility for todo.txt files.

File bug reports here.

Build status

Given two files, todotxt-merge produces output with:

  1. All tasks from both lists are in the output
  2. Tasks matched ignoring metadata (priority, projects, lists, dates, completed)
  3. Matched tasks include metadata from both
  4. The second file metadata overrides the first file in the case of metadata conflicts

Rule 2 means that if a task is completed in one list, it's completed in the output.


$ todotxt-merge todo.sync-conflict-20210703-174230-73BTXZI.txt todo.txt > new-todo.txt

Also in this repository is a bash script that will watch a directory for Syncthing sync-conflict files and merge them up. It uses fswatch and merges the conflict files in creation timestamp order, rolling every conflict file for the watched file into an ultimate merged file. It then moves all sync-conflict files and the watched file into a backup directory, and replaces the watched file with the merged version. To use this script, make sure fswatch is installed and todotxt- merge is in your path somewhere, and then run:

$ synctodo ~/somedir/todo.txt
Watching /home/you/somedir/todo.txt
backups will be in /home/you/.cache/synctodo/backup_9uVuGA

If you run it with the -d option, it'll print everything it does.


Install it:

$ go install ser1.net/todotxt-merge

Or build it:

$ hg clone hg.sr.ht/~ser/todotxt-merge
$ cd todotxt-merge
$ go build .

Or download binaries. My PGP ID for verifying the sig is 5E0D7ABD6668FDD1 (on public keyservers).

#Rationale, future, use case

I might add Levestein distance for better task matching; otherwise, it's done.

The tool is in support of resolving sync conflicts when two users are editing the same todo file. For example, my wife and I share a shopping list, which is synced across our various devices via Syncthing. Because Syncthing doesn't do merging, and because Syncthing can often take its time actually syncing directories, we frequently end up with sync conflict files. My solution is composed of fswatch and todotxt- merge: I have the devices set to sync to a home server, on which fswatch is running. When it detects a new sync conflict file, it runs todotxt-merge and resolves the conflict.

#Notes (mostly for me)

An earlier version duplicated project tags; this removes them:

sed -i -r 's/(@\w+) (\1)/\1/g' todo.txt


todotxt-merge is 129 LOC, thanks to the heavy lifting being done by @JamesClonk's go-todotxt.