2019-04-10 00:34:41 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
NOTES_DIR="$HOME/Nextcloud/Notes"
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
echo "nnotes expects 0, 1, or 2 arguments"
|
2019-11-14 18:20:42 +00:00
|
|
|
echo "Edit from root notes dir"
|
|
|
|
echo " nnotes"
|
|
|
|
echo "Create a note in root dir"
|
|
|
|
echo " nnotes <note name>"
|
|
|
|
echo "Create a note in sub dir"
|
|
|
|
echo " nnotes <subdir> <note name>"
|
2019-04-10 00:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
if [ ! -d "$NOTES_DIR" ]; then
|
|
|
|
echo "No directory $NOTES_DIR. Please sync your notes"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
validate
|
|
|
|
|
|
|
|
# nvim "$NOTES_DIR" -c ":cd $NOTES_DIR"
|
2019-11-14 18:20:42 +00:00
|
|
|
cd "$NOTES_DIR" || { echo "Could change to notes dir" ; exit 1; }
|
2019-04-10 00:34:41 +00:00
|
|
|
|
2019-11-14 18:20:42 +00:00
|
|
|
mkdir -p "$CATEGORY"
|
|
|
|
nvim "$CATEGORY/$FILE"
|
2019-04-10 00:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case $# in
|
|
|
|
0)
|
|
|
|
CATEGORY=.
|
|
|
|
FILE=.
|
|
|
|
;;
|
|
|
|
1)
|
|
|
|
CATEGORY=.
|
2019-10-30 00:56:25 +00:00
|
|
|
FILE="$1.md"
|
2019-04-10 00:34:41 +00:00
|
|
|
;;
|
|
|
|
2)
|
|
|
|
CATEGORY="$1"
|
2019-10-30 00:56:25 +00:00
|
|
|
FILE="$2.md"
|
2019-04-10 00:34:41 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown number of arugments"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2019-11-14 18:20:42 +00:00
|
|
|
main "$@"
|