Docs

Save Hook

The save hook lets you run code every time Nota auto-saves a file:

  1. Open the Go → Command Palette... ⇧⌘p and search for "Open Save Hook". This will open the save hook with some instructions inside.
  2. You can now write to the saved file (e.g. format the text) or work with an external system (e.g. Git).

Here is a sample save.js hook that ensures the file ends with a newline:

#!/usr/bin/env node

// @parameters file

const fs = require('fs')
const filePath = process.argv[2]
const text = fs.readFileSync(filePath, 'utf8')
if (!text.endsWith('\n')) {
    fs.appendFileSync(filePath, `\n`)
}

Save hook is located at path/to/your/workspace/.nota/hooks/save.extension (e.g. ~/Dropbox/Nota/.nota/hooks/save.js).

@parameters

If you aren't familiar with the @parameters syntax, read the article first.

@parameters tells Nota which values to pass to the script:

Ideas for hooks