- echo "listing all notes"
- [ $PLAIN == true ] && echo "output is plain text" || echo "output is colored"
- 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
+ # [ $PLAIN == true ] && echo "output is plain text" || echo "output is colored"
+ if [[ $(ls -A $NOTESDIR) ]]; then
+ echo "listing all notes"
+ echo ""
+ echo "[ID] [TITLE] [SIZE]"
+ for i in ${NOTESDIR}/*; do
+ SIZE=$(du -k $i |cut -f 1)
+ 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} ${SIZE}kb"
+ done
+ else
+ echo "no notes yet. You can add your first one with: ${BASENAME} -a \"your note title\""
+ fi