From 89f23a49b29d97fe65442b39336b0ad79add4307 Mon Sep 17 00:00:00 2001 From: Ayo Date: Mon, 23 Jun 2025 10:38:42 +0200 Subject: [PATCH] feat(notes): new notes management script --- ayo.sh | 21 ++++++++++++--------- journal.sh | 30 +++++++----------------------- notes.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 32 deletions(-) create mode 100755 notes.sh diff --git a/ayo.sh b/ayo.sh index 8945d56..b8c730e 100755 --- a/ayo.sh +++ b/ayo.sh @@ -4,24 +4,27 @@ case $1 in ## SHORTCUTS js) # js - journal sync - . ${HOME}/Projects/scripts/journal.sh sync + . ${HOME}/Projects/scripts/journal.sh sync $2 $3 $4 $5 $6 $7 $8 $9 ;; - jn) # js - journal note - . ${HOME}/Projects/scripts/journal.sh note + ns) # js - journal sync + . ${HOME}/Projects/scripts/notes.sh sync $2 $3 $4 $5 $6 $7 $8 $9 ;; ## SCRIPTS + n | notes) + . ${HOME}/Projects/scripts/notes.sh $2 $3 $4 $5 $6 $7 $8 $9 + ;; + j | journal) + . ${HOME}/Projects/scripts/journal.sh $2 $3 $4 $5 $6 $7 $8 $9 + ;; + c | config) + echo 'Config script in-progress' + ;; m | mac) quickemu --vm macos-monterey.conf --width 1920 --height 1080 ;; ms) quickemu --vm macos-monterey.conf --kill ;; - j | journal) - . ${HOME}/Projects/scripts/journal.sh $2 $3 $4 $5 - ;; - c | config) - echo 'Config script in-progress' - ;; esac diff --git a/journal.sh b/journal.sh index 4a5d061..3a48fc2 100755 --- a/journal.sh +++ b/journal.sh @@ -7,6 +7,8 @@ command=$1 journal_dir="${notes_dir}/Journal" month_dir=$(date +"%m %b") +getopts "t" typora; #check if -t flag is given + if [ "$1" = "sync" ]; then { path="${notes_dir}/" @@ -19,28 +21,6 @@ if [ "$1" = "sync" ]; then # Report; TODO: write log echo ">>> Sync failed" } -elif [ "$1" = "note" ]; then - { - read -p "Enter file name: " title - file_name=$title.md - full_path="${notes_dir}/${file_name}" - - # IF Not Exists: create file & echo date - if ! test -f "$full_path"; then - install -Dv /dev/null "$full_path" - # TODO: update to correct heading from old entries - heading="# $title" - echo $heading > "$full_path" - date_heading=$(date +'%b %d, %Y, %a %r') - echo $date_heading >> "$full_path" - fi - - # Open in editor - vim "$full_path" - - } || { - echo ">>> New note failed" - } else { file_name=$(date +'%m.%d.%Y').md @@ -55,7 +35,11 @@ else fi # Open in editor - vim "$full_path" + if [ "$typora" = "t" ]; then + typora "$full_path" + else + vim "$full_path" + fi } || { # Report; TODO: write log echo ">>> " $full_path diff --git a/notes.sh b/notes.sh new file mode 100755 index 0000000..c39c426 --- /dev/null +++ b/notes.sh @@ -0,0 +1,50 @@ +#! /usr/bin/bash + +## notes management + +# Load config +. ${HOME}/ayo.conf + +# TODO: write log for echoes with >>> + +command=$1 + +getopts "t" typora; #check if -t flag is given + +if [ "$1" = "sync" ]; then + { + path="${notes_dir}/" + cd "$path" + git pull + git add . + git commit -m "[script] update/add entrie/s" + git push + } || { + echo ">>> Sync failed" + } +else + { + read -p "Enter file name: " title + file_name=$title.md + full_path="${notes_dir}/${file_name}" + + # IF Not Exists: create file & echo date + if ! test -f "$full_path"; then + install -Dv /dev/null "$full_path" + # TODO: update to correct heading from old entries + heading="# $title" + echo $heading > "$full_path" + date_heading=$(date +'%b %d, %Y, %a %r') + echo $date_heading >> "$full_path" + fi + + # Open in editor + if [ "$typora" = "t" ]; then + typora "$full_path" + else + vim "$full_path" + fi + } || { + echo ">>> New note failed" + } +fi