From fb71118327216a21f6732161dc3721496a16370d Mon Sep 17 00:00:00 2001 From: danix Date: Wed, 29 Mar 2023 11:19:55 +0200 Subject: Separated script into multiple files for easier management. Added Makefile --- SOURCE/CORE/core-add.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 SOURCE/CORE/core-add.sh (limited to 'SOURCE/CORE/core-add.sh') diff --git a/SOURCE/CORE/core-add.sh b/SOURCE/CORE/core-add.sh new file mode 100644 index 0000000..aa9d451 --- /dev/null +++ b/SOURCE/CORE/core-add.sh @@ -0,0 +1,23 @@ +function addnote() { + # remove eventually existing temp DB file + if [[ -f $TMPDB ]]; then + rm $TMPDB + fi + + NOTETITLE="$1" + echo "adding new note - \"$NOTETITLE\"" + # shellcheck disable=SC2086 + LASTID=$($JQ '.notes[-1].id // 0 | tonumber' $DB) + # [ "" == $LASTID ] && LASTID=0 + NOTEID=$(( LASTID + 1 )) + # shellcheck disable=SC2086 + touch ${NOTESDIR}/${NOW} + # shellcheck disable=SC2016 + $JQ --arg i "$NOTEID" --arg t "$NOTETITLE" --arg f "$NOW" '.notes += [{"id": $i, "title": $t, "file": $f}]' "$DB" > $TMPDB + # shellcheck disable=SC2086 + mv $TMPDB $DB + # example for alacritty: + # alacritty --class notes --title notes -e /usr/bin/vim ... + # shellcheck disable=SC2086,SC2091 + $(${TERMINAL} ${TERM_OPTS} ${EDITOR} ${NOTESDIR}/${NOW}) +} -- cgit v1.2.3