From 67cdd470655567ea08e9ff95756e7f90dfe324ee Mon Sep 17 00:00:00 2001 From: Ayo Date: Sun, 22 Jun 2025 15:28:58 +0200 Subject: [PATCH] feat(journal): sync command --- ayo.sh | 3 +++ journal.sh | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ayo.sh b/ayo.sh index e79adcf..b0c4266 100755 --- a/ayo.sh +++ b/ayo.sh @@ -1,6 +1,9 @@ #! /usr/bin/bash case $1 in + js) + . ${HOME}/Projects/scripts/journal.sh sync + ;; j | journal) . ${HOME}/Projects/scripts/journal.sh $2 $3 $4 $5 ;; diff --git a/journal.sh b/journal.sh index e8158fa..93307ca 100755 --- a/journal.sh +++ b/journal.sh @@ -4,12 +4,23 @@ . ${HOME}/.ayo.config command=$1 +journal_dir="${notes_dir}/Journal" +month_dir=$(date +"%m %b") + if [ "$1" = "sync" ]; then - echo 'sync' #TODO: git pull, git add ... git commit, git push + { + path="${journal_dir}/${month_dir}/" + cd "$path" + git pull + git add . + git commit -m "[script] update/add entrie/s" + git push + } || { + # Report; TODO: write log + echo ">>> Sync failed" + } else - journal_dir="${notes_dir}/Journal" - month_dir=$(date +"%m %b") file_name=$(date +'%m.%d.%Y').md full_path="${journal_dir}/${month_dir}/${file_name}"