Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
686 B

  1. #!/bin/bash
  2. NOTES_FOLDER="$HOME/Documents/Notes"
  3. JSON_DB="$NOTES_FOLDER/books.yml"
  4. function exists_or_create() {
  5. if [[ -f "$2" ]]; then
  6. echo "Not Creating the note: File is already there"
  7. else
  8. echo -e "$1 \n$2"
  9. echo -e "# Book: $1\n" > "$2"
  10. cat <<EOF >> $JSON_DB
  11. - book: "$1"
  12. hash: "$(basename $2)"
  13. date: "$(date '+%d/%m/%Y %H:%M:%S')"
  14. EOF
  15. fi
  16. }
  17. function add_annotation() {
  18. xclip -out -selection clipboard >> "$1"
  19. echo -e "\n> <!!>\n" >> $1
  20. }
  21. hashed_filename="$NOTES_FOLDER/$(md5sum "$1" | cut -f1 -d' ').md"
  22. filename=$(basename "$@")
  23. exists_or_create "$filename" "$hashed_filename"
  24. add_annotation "$hashed_filename"