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"
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
|
|
cd $NOTES_DIR
|
|
|
|
|
|
|
|
mkdir -p $CATEGORY
|
2019-10-30 00:56:25 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
main $*
|