Git based notes tracking/VCS daemon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
distek 4f6e7b6894 Updated readme 1 week ago
README.md Updated readme 1 week ago
example.yaml Add git over SSH, other changes: 1 week ago
go.mod Add git over SSH, other changes: 1 week ago
go.sum Add git over SSH, other changes: 1 week ago
main.go Add git over SSH, other changes: 1 week ago

README.md

notesd

Note syncing daemon for use with git

Description

notesd will monitor whatever directory you specify in the configuration. Any time there is a filesystem event that also made the git tree dirty, it will add/remove/stage whatever was changed. It will then create a generic commit with the exact time according to your system. And finally push it to the repo your specified, all without manual intervention.

I wrote this just to keep some notes up to date when moving between workstations/personal machines. I'm leaving it out here for anyone to use.

Please check the Notes section below for some tips on usage.

Installation

go build -o notesd main.go

Copy the binary notesd to wherever you want that's in your $PATH. I use ~/.local/bin

Make the config directory:

mkdir ~/.config/notesd

And create or copy over the example.yaml config as ~/.config/notesd/config.yaml and modify it to fit your setup.

  • HTTP/S: You will need to get an application API key from your git service of choice and add that to the config as api-key: "[key-goes-here]" - Example:
api-key: "22eca4c864bac4cb09ec49544a8ede83e660d020"
  • SSH: Modify the config to include your git username (usually "git") for the key ssh-user
ssh-user: "git"

Example configuration:

# Folders to watch
# Make sure it initialize your repo before starting notesd
folder: "~/Notes"

# Force pull remote on start to get the latest updates
force-pull: true

# Git information
git-repo:
  username: "distek"
  author: "distek"
  email: "distek@protonmail.com"
  api-key: ""
  ssh-user: "git"

Git repo setup:

Create a git repo on whatever service you want to use.

Rather clone or initialize that repo locally.

Modify the notesd configuraiton to reflect which directory it should monitor, and all necessary repo details.

General Usage

Configure your DE/WM to run the binary on startup, or launch it later if you don't want it constantly monitoring the git directory.

For example: Sway/i3:

exec --no-startup-id notesd

Check the Notes section for information regarding SSH

Notes

This has been tested on the following systems:

  • Linux (any so long as git is installed it seems)
  • MacOS 10.14+ (though I'm sure it will work on older OSX versions, so long as git is installed)

Note on SSH:

  • In order to use SSH correctly with this, you should start the daemon similar to this:

#!/bin/bash

eval $(ssh-agent)
ssh-add

notesd &
  • Reason being: https://github.com/src-d/go-git/issues/550
    • There's some issue where it doesn't appear the SSH portion of our git package can utilize the systems default SSH agent. I don't know why. If you can fix these, please submit a patch.

A note on directories and the files contained within:

  • notesd will not check to see if there were changes if it was not running at the time of the change. If you want it to see changes, you just need to touch whatever files/directories you modified while it is running. You can also just add/commit/push changes yourself and any changes after notesd is started will be detected.

  • This is most notably an issue with directories and the files contained within.

    • If you create a directory, add a file, and then start notesd, and then modify a file in that directory, it will not notice the change. touch the directory first, and it will add everything recursively from there.

Issues

Please raise an issue in this repo with any errors you received, and we'll try and figure out what's going on. This should be pretty solid unless you misconfigured it.