sync operations now check for last sync before running again. It's possible to set...
[bash-notes.git] / SOURCE / CORE / core-list.sh
CommitLineData
b1e2a018 1listnotes() {
cf6d89bc 2 # attempt syncing before listing all notes
3 gitsync
fb711183 4 # [ $PLAIN == true ] && echo "output is plain text" || echo "output is colored"
5 if [[ $(ls -A "$NOTESDIR") ]]; then
6 if [ $PLAIN == false ]; then
7 echo "listing all notes"
8 echo ""
9 fi
10 [ $PLAIN == false ] && echo "[ID] [TITLE] [CREATED]"
11 for i in "${NOTESDIR}"/*; do
12 # shellcheck disable=SC2155
13 local fname=$(basename $i)
14 DATE=$(date -d @${fname} +"%d/%m/%Y %R %z%Z")
15 # shellcheck disable=SC2016,SC2086
16 TITLE=$($JQ -r --arg z $(basename $i) '.notes[] | select(.file == $z) | .title' $DB)
17 # shellcheck disable=SC2016,SC2086
18 ID=$($JQ -r --arg z $(basename $i) '.notes[] | select(.file == $z) | .id' $DB)
19 [ $PLAIN == false ] && echo "[${ID}] ${TITLE} ${DATE}" || echo "${ID} - ${TITLE} - ${DATE}"
20 done
21 else
22 echo "no notes yet. You can add your first one with: ${BASENAME} -a \"your note title\""
23 fi
24}