feat(notes): new notes management script

This commit is contained in:
Ayo Ayco 2025-06-23 10:38:42 +02:00
parent 1cb64f0cf2
commit 89f23a49b2
3 changed files with 69 additions and 32 deletions

21
ayo.sh
View file

@ -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

View file

@ -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
if [ "$typora" = "t" ]; then
typora "$full_path"
else
vim "$full_path"
fi
} || {
# Report; TODO: write log
echo ">>> " $full_path

50
notes.sh Executable file
View file

@ -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