mirror of
https://github.com/ViViDboarder/shoestrap.git
synced 2024-12-05 02:36:47 +00:00
53 lines
955 B
Bash
Executable File
53 lines
955 B
Bash
Executable File
#! /bin/bash
|
|
|
|
NOTES_DIR="$HOME/Nextcloud/Notes"
|
|
|
|
function usage() {
|
|
echo "nnotes expects 0, 1, or 2 arguments"
|
|
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>"
|
|
}
|
|
|
|
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" || { echo "Could change to notes dir" ; exit 1; }
|
|
|
|
mkdir -p "$CATEGORY"
|
|
nvim "$CATEGORY/$FILE"
|
|
}
|
|
|
|
case $# in
|
|
0)
|
|
CATEGORY=.
|
|
FILE=.
|
|
;;
|
|
1)
|
|
CATEGORY=.
|
|
FILE="$1.md"
|
|
;;
|
|
2)
|
|
CATEGORY="$1"
|
|
FILE="$2.md"
|
|
;;
|
|
*)
|
|
echo "Unknown number of arugments"
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
main "$@"
|