Docs
Paste Hook
The paste hook lets you modify the pasted text:
- Open the Go → Command Palette... ⇧⌘p and search for "Open Paste Hook". This will create a hook that does nothing but passes the clipboard text as a first argument
$1. - Modify the hook and call
printf "%s" "with the text that you want inserted". Usingprintfinstead ofechobecauseechocauses problems in some edge cases.
Here is a sample paste hook that replaces the word "Nota" with "the awesome Nota":
#!/bin/bash
# @parameters clipboardText
printf "%s" "${1/Nota/the awesome Nota}"
Paste hook is located at path/to/your/workspace/.nota/hooks/paste.extension (e.g. ~/Dropbox/Nota/.nota/hooks/paste.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:
clipboardText– the text contents of the clipboardselectedText– the currently selected text, empty string if no text is selectedfile– the path to the currently opened fileworkspace– the path to the currently opened workspace
Ideas for hooks
- Privacy URLs – A lot of URLs have tracking data. Why not remove the tracking data for your most common URLs?
- Paste URL over text – Create a markdown link when pasting an URL and there is a text selected. A small productivity hack.
- Format pasted text – You may want to strip indents, replace a specific word with another, replace an URL with a markdown link.