Files
vns/src/includes/delete.sns.sh
2016-02-15 16:22:14 -06:00

19 lines
572 B
Bash

function delete(){
# Requires: $NOTE, $NOTE_DIR
# Given a valid $NOTE, delete removes $NOTE from sns.
if [ -e "$NOTES_DIR/$NOTE" ]; then
rm "$NOTES_DIR/$NOTE"
printf " - %s\n" "Deleted note: ${NOTE%.*}."
#Cleanup empty notebooks/sections]
find "$NOTES_DIR" -mindepth 1 -type d | tac |\
while read -r DIR ; do
if [ ! "$(ls -A $DIR)" ]; then
rmdir "$DIR"
fi
done
else
>&2 printf " $RED_COLOR!$RESET_COLOR %s\n" "Note ${NOTE%.*} does not exist."
fi
}