Added functionality to remove empty notebooks/sections

This commit is contained in:
Jon-William Lewis
2016-02-15 16:22:14 -06:00
parent 0be408290d
commit d1140974f4

View File

@@ -5,6 +5,13 @@ function delete(){
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