Reworked print function

This commit is contained in:
Jon-William Lewis
2016-01-25 21:00:43 -06:00
parent 8fc731aaa0
commit 2d8db83c3c
6 changed files with 29 additions and 95 deletions

View File

@@ -1,31 +1,8 @@
function list(){
if [ -d "$BASE_DIR"/"$NOTEBOOK" ]; then
printf "\nNotes in %s:\n" "$(basename "$NOTEBOOK")"
NOTES=(
$(find "$BASE_DIR"/"$NOTEBOOK" -name "*.$EXT" -print0 |\
sed s:"$BASE_DIR"/"$NOTEBOOK"/: " " :g |\
sed -e s:".$EXT"::g | tr "/" " ")
)
let i=0
for NOTE in "${NOTES[@]}"; do
if [ -d "$BASE_DIR"/"$NOTEBOOK"/"$NOTE" ]; then
if [ "$LAST_SECTION" != "$NOTE" ]; then
printf " Section: %s\n" "$NOTE"
fi
LAST_SECTION="$NOTE"
else
#if [ $(($i % 1)) -eq 0 ]; then
# printf "\n "
#fi
printf " %s\n" "$NOTE"
fi
let i++
printf "+%s\n" "$NOTEBOOK"
find "$BASE_DIR"/"$NOTEBOOK" -type f | while read NOTE; do
printf " -%s\n" "$(basename $NOTE | cut -d . -f 1)"
done
printf "\n"
else
echo ""
echo "ERROR: Notebook $NOTEBOOK does not exist."
echo ""
fi
}