|
|
- #!/bin/bash
-
- NOTES_FOLDER="$HOME/Documents/Notes"
- JSON_DB="$NOTES_FOLDER/books.yml"
-
-
- function exists_or_create() {
- if [[ -f "$2" ]]; then
- echo "Not Creating the note: File is already there"
- else
- echo -e "$1 \n$2"
- echo -e "# Book: $1\n" > "$2"
- cat <<EOF >> $JSON_DB
- - book: "$1"
- hash: "$(basename $2)"
- date: "$(date '+%d/%m/%Y %H:%M:%S')"
- EOF
- fi
- }
-
- function add_annotation() {
- xclip -out -selection clipboard >> "$1"
- echo -e "\n> <!!>\n" >> $1
- }
-
-
- hashed_filename="$NOTES_FOLDER/$(md5sum "$1" | cut -f1 -d' ').md"
- filename=$(basename "$@")
-
-
- exists_or_create "$filename" "$hashed_filename"
- add_annotation "$hashed_filename"
|