aboutsummaryrefslogtreecommitdiffstats
path: root/notes.sh
diff options
context:
space:
mode:
authordanix <danix@danix.xyz>2023-03-24 16:26:31 +0100
committerdanix <danix@danix.xyz>2023-03-24 16:26:31 +0100
commit44abbfe7d30b1a3460500aef77bc6f4b7b3b95fa (patch)
tree0450a8187838682576d6aaa7578cb1cf173861e9 /notes.sh
parentd80ac20a06af4d46b263da70ad6de2c37ad6d5ec (diff)
downloadbash-notes-44abbfe7d30b1a3460500aef77bc6f4b7b3b95fa.tar.gz
bash-notes-44abbfe7d30b1a3460500aef77bc6f4b7b3b95fa.zip
we can now edit a note and list all notes
Diffstat (limited to 'notes.sh')
-rw-r--r--notes.sh20
1 files changed, 18 insertions, 2 deletions
diff --git a/notes.sh b/notes.sh
index 3fc89e3..edec94d 100644
--- a/notes.sh
+++ b/notes.sh
@@ -97,11 +97,27 @@ function addnote() {
}
function listnotes() {
- echo "list all notes"
+ echo "listing all notes"
+ echo ""
+ echo "[ID] [TITLE]"
+ for i in ${NOTESDIR}/*; do
+ TITLE=$($JQ -r --arg z $(basename $i) '.notes[] | select(.file == $z) | .title' $DB)
+ ID=$($JQ -r --arg z $(basename $i) '.notes[] | select(.file == $z) | .id' $DB)
+
+ echo "[${ID}] ${TITLE}"
+ done
}
function editnote() {
- echo "edit note \"${1}\""
+ TITLE=$($JQ --arg i $1 '.notes[] | select(.id == $i) | .title' $DB)
+ FILE=$($JQ -r --arg i $1 '.notes[] | select(.id == $i) | .file' $DB)
+ if [ "$TITLE" ]; then
+ echo "editing note $TITLE"
+ $(${TERMINAL} --class notes --title notes -e ${EDITOR} ${NOTESDIR}/${FILE})
+ else
+ echo "note not found"
+ exit 1
+ fi
}
function datenote() {