For a long time I’ve toyed with the idea of replacing Simplenote with a Fossil repo of text files, more from an “owning your own data” point of view than anything else, but more “recently” since I stopped using Vim and switched to Helix. It’s probably not happening any time soon as Simplenote is still too convienent on mobile, but I thought I’d have a little play just because Fossil’s auto-sync is really neat.

  1. Created a repo on my (this) server, but a private one for now, not public
  2. Cloned that via ssh to my local machine: fossil clone ssh://me@linode/Code/fossil/repos/notes.fossil
  3. Then added a little “hook” to Helix via my mksh config like so:

     function hx {
       /usr/pkg/bin/hx $@
       if [[ $(pwd) == '/home/simon/Code/fossil/checkouts/notes' ]]
       then
         if [[ $(fossil extras) != "" ]]
         then
           fossil add $(fossil extras)
         fi
         fossil commit -m 'Auto-sync notes'
       fi
     }
    

    The idea being that if I am editing a note and then exit and save, Fossil will then automatically sync changes, including adding it if it’s a new note. The only downside to this is that if I suspend Helix (Ctrl+z) then that also triggers this and if I resume (fg) and then quit it won’t automatically sync.

  4. So I’ve also added a keybinding of fs to Helix to manually trigger a sync:

    [keys.normal.f]
    s = [":write", ':sh if [ "$(fossil extras)" != "" ]; then fossil add $(fossil extras); fi; fossil commit -m "Auto-sync notes"']
    

    (Slightly different syntax as it’s sh as opposed to mksh)

I can’t see me fully switching from Simplenote yet as I don’t have a good mobile solution (apart from using a sftp client on Android… hmmm… maybe), but it’s interesting to play about.