2 # attempt syncing before adding a note
4 # remove eventually existing temp DB file
5 if [[ -f $TMPDB ]]; then
10 RTITLE
=$
(random_title
)
13 read -r -p "Title: " TITLE
24 # [[ -z "$1" ]] && NOTETITLE="$RTITLE" || NOTETITLE="$1"
25 echo "adding new note - \"$NOTETITLE\""
26 # shellcheck disable=SC2086
27 LASTID
=$
($JQ '.notes[-1].id // 0 | tonumber' $DB)
28 # [ "" == $LASTID ] && LASTID=0
29 NOTEID
=$
(( LASTID
+ 1 ))
30 # shellcheck disable=SC2086
31 touch ${NOTESDIR}/${NOW}
32 # shellcheck disable=SC2016
33 $JQ --arg i
"$NOTEID" --arg t
"$NOTETITLE" --arg f
"$NOW" '.notes += [{"id": $i, "title": $t, "file": $f}]' "$DB" > $TMPDB
34 # shellcheck disable=SC2086
36 # example for alacritty:
37 # alacritty --class notes --title notes -e /usr/bin/vim ...
38 # shellcheck disable=SC2086,SC2091
39 $
(${TERMINAL} ${TERM_OPTS} ${EDITOR} ${NOTESDIR}/${NOW})
40 # add note to git and push to remote