2 # attempt syncing before adding a note
4 # remove eventually existing temp DB file
5 if [[ -f $TMPDB ]]; then
10 [[ -z "$1" ]] && NOTETITLE
="$RTITLE" || NOTETITLE
="$1"
11 echo "adding new note - \"$NOTETITLE\""
12 # shellcheck disable=SC2086
13 LASTID
=$
($JQ '.notes[-1].id // 0 | tonumber' $DB)
14 # [ "" == $LASTID ] && LASTID=0
15 NOTEID
=$
(( LASTID
+ 1 ))
16 # shellcheck disable=SC2086
17 touch ${NOTESDIR}/${NOW}
18 # shellcheck disable=SC2016
19 $JQ --arg i
"$NOTEID" --arg t
"$NOTETITLE" --arg f
"$NOW" '.notes += [{"id": $i, "title": $t, "file": $f}]' "$DB" > $TMPDB
20 # shellcheck disable=SC2086
22 # example for alacritty:
23 # alacritty --class notes --title notes -e /usr/bin/vim ...
24 # shellcheck disable=SC2086,SC2091
25 $
(${TERMINAL} ${TERM_OPTS} ${EDITOR} ${NOTESDIR}/${NOW})
26 # add note to git and push to remote