Changes: Split script into several different files for easier editting Added build.sh to compile Simple Note System from tree Changed config file to config folder; $HOME/.sns now contains configuration and notes Testing: Script runs and produces help screen; no further testing done.
40 lines
778 B
Bash
40 lines
778 B
Bash
# list.sns.sh
|
|
|
|
if [ -n "$LIST" ]; then
|
|
NOTEBOOK="$NAME" #In case of a list command, arg parsing fails.
|
|
if [ -z "$NOTEBOOK" ]; then
|
|
echo " ERROR: Insufficient arguments"
|
|
help
|
|
exit
|
|
else
|
|
if [ -d "$BASEDIR"/"$NOTEBOOK" ]; then
|
|
|
|
echo ""
|
|
printf "Notes in $(basename $NOTEBOOK):"
|
|
echo ""
|
|
NOTES=( $(find $BASEDIR/$NOTEBOOK -name "*.$EXT" -print0 | sed s:$BASEDIR/$NOTEBOOK/:" ":g | sed -e s:".$EXT"::g | tr "/" " ") )
|
|
let i=0
|
|
for NOTE in ${NOTES[@]}; do
|
|
if [ -d $BASEDIR/$NOTEBOOK/$NOTE ]; then
|
|
if [ "$LAST_SECTION" != "$NOTE" ]; then
|
|
printf " Section: $NOTE\n"
|
|
fi
|
|
LAST_SECTION=$NOTE
|
|
else
|
|
#if [ $(($i % 1)) -eq 0 ]; then
|
|
# printf "\n "
|
|
#fi
|
|
printf " $NOTE\n"
|
|
fi
|
|
let i++
|
|
done
|
|
printf "\n"
|
|
else
|
|
echo ""
|
|
echo "ERROR: Notebook $NOTEBOOK does not exist."
|
|
echo ""
|
|
fi
|
|
fi
|
|
exit
|
|
fi
|