Skip to content

Instantly share code, notes, and snippets.

@melonamin
Last active April 22, 2024 20:14
Show Gist options
  • Save melonamin/d2642141e7c35d09e235b1f653c6bc56 to your computer and use it in GitHub Desktop.
Save melonamin/d2642141e7c35d09e235b1f653c6bc56 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title FSNotes Create New Note
# @raycast.mode silent
# Optional parameters:
# @raycast.icon ./images/fsnotes-icon.png
# @raycast.packageName FSNotes
# @raycast.argument1 { "type": "text", "placeholder": "Text", "optional": true }
# Documentation:
# @raycast.author melonamin
# @raycast.authorURL https://github.com/melonamin
# Description:
# @raycast.description Create a new note in FSNotes. Empty note or with provided text.
urlencode() {
python3 -c "import sys, urllib.parse; print(urllib.parse.quote(sys.stdin.read(), safe=''))"
}
text=$(echo "$1" | urlencode)
if [ -n "$text" ]; then
open "fsnotes://new/?txt=${text}"
else
open "fsnotes://new"
fi
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title FSNotes Search
# @raycast.mode silent
# Optional parameters:
# @raycast.icon ./images/fsnotes-icon.png
# @raycast.packageName FSNotes
# @raycast.argument1 { "type": "text", "placeholder": "Query...", "optional":false }
# Documentation:
# @raycast.author melonamin
# @raycast.authorURL https://github.com/melonamin
# Description:
# @raycast.description Search notes in FSNotes by keywords.
urlencode() {
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
}
encodedQuery=$(urlencode "$1")
searchURL="fsnotes://find/${encodedQuery}"
open "$searchURL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment