Paste Hook
The paste hook lets you modify the pasted text:
- Open the View → Command Palette... ⇧⌘p and search for "Open Paste Hook". This will create a hook that does nothing but passes the clipboard text as
$1
. - Modify the hook and call
echo
to return the value that will be pasted inside Nota.
Here is an example that replaces the word "Nota" with "the awesome Nota":
#!/bin/bash
# @parameters clipboardText
echo "${1/Nota/the awesome Nota}"
@parameters
@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
Multiple values should be separated by spaces: @parameters selectedText file workspace
. This will make $1
the selected text, $2
the currently edited file, and $3
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.