feat: auto sync for notes & journal

This commit is contained in:
Ayo Ayco 2025-06-23 14:34:00 +02:00
parent 8909dbe41e
commit 5fcf06c7aa
2 changed files with 31 additions and 32 deletions

View file

@ -13,14 +13,13 @@ getopts "t" typora; #check if -t flag is given
file_name=$(date +'%m.%d.%Y').md file_name=$(date +'%m.%d.%Y').md
full_path="${journal_dir}/${month_dir}/${file_name}" full_path="${journal_dir}/${month_dir}/${file_name}"
if [ "$1" = "sync" ]; then notesSync
notesSync
elif [ "$1" = "append" ]; then if [ "$1" = "append" ]; then
{ {
read -p "Add thought: " thought read -p "Add thought: " thought
time=$(date +'%r') time=$(date +'%r')
echo $'\n'\> \[$time\]$'\n'\> $thought >> "$full_path" echo $'\n'\> \[$time\]$'\n'\> $thought >> "$full_path"
notesSync
} || { } || {
echo ">>> Append failed" echo ">>> Append failed"
} }
@ -40,9 +39,10 @@ else
else else
vim "$full_path" vim "$full_path"
fi fi
notesSync
} || { } || {
# Report; TODO: write log # Report; TODO: write log
echo ">>> " $full_path echo ">>> " $full_path
} }
fi fi
notesSync

View file

@ -12,10 +12,9 @@ command=$1
getopts "t" typora; #check if -t flag is given getopts "t" typora; #check if -t flag is given
if [ "$1" = "sync" ]; then notesSync
notesSync
else {
{
read -p "Enter file name: " title read -p "Enter file name: " title
file_name=$title.md file_name=$title.md
full_path="${notes_dir}/${file_name}" full_path="${notes_dir}/${file_name}"
@ -37,8 +36,8 @@ else
vim "$full_path" vim "$full_path"
fi fi
notesSync } || {
} || {
echo ">>> New note failed" echo ">>> New note failed"
} }
fi
notesSync