feat: shared functions.sh with notesSync function; quiet git operations"
This commit is contained in:
parent
1681745c09
commit
888ff8ef55
3 changed files with 23 additions and 22 deletions
14
functions.sh
Normal file
14
functions.sh
Normal file
|
@ -0,0 +1,14 @@
|
|||
notesSync() {
|
||||
{
|
||||
path="${notes_dir}/"
|
||||
cd "$path"
|
||||
git pull --quiet
|
||||
git add .
|
||||
git commit -m "[script] update/add entrie/s" --quiet
|
||||
git push --quiet
|
||||
echo ">>> Sync success"
|
||||
} || {
|
||||
# Report; TODO: write log
|
||||
echo ">>> Sync failed"
|
||||
}
|
||||
}
|
17
journal.sh
17
journal.sh
|
@ -1,7 +1,8 @@
|
|||
#! /usr/bin/bash
|
||||
|
||||
# Load config
|
||||
# Load config & functions
|
||||
. ${HOME}/ayo.conf
|
||||
. functions.sh
|
||||
|
||||
command=$1
|
||||
journal_dir="${notes_dir}/Journal"
|
||||
|
@ -13,22 +14,13 @@ file_name=$(date +'%m.%d.%Y').md
|
|||
full_path="${journal_dir}/${month_dir}/${file_name}"
|
||||
|
||||
if [ "$1" = "sync" ]; then
|
||||
{
|
||||
path="${notes_dir}/"
|
||||
cd "$path"
|
||||
git pull
|
||||
git add .
|
||||
git commit -m "[script] update/add entrie/s"
|
||||
git push
|
||||
} || {
|
||||
# Report; TODO: write log
|
||||
echo ">>> Sync failed"
|
||||
}
|
||||
notesSync
|
||||
elif [ "$1" = "append" ]; then
|
||||
{
|
||||
read -p "Add thought: " thought
|
||||
time=$(date +'%r')
|
||||
echo $'\n'\[$time\] $thought$'\n' >> "$full_path"
|
||||
notesSync
|
||||
} || {
|
||||
echo ">>> Append failed"
|
||||
}
|
||||
|
@ -48,6 +40,7 @@ else
|
|||
else
|
||||
vim "$full_path"
|
||||
fi
|
||||
notesSync
|
||||
} || {
|
||||
# Report; TODO: write log
|
||||
echo ">>> " $full_path
|
||||
|
|
14
notes.sh
14
notes.sh
|
@ -4,6 +4,7 @@
|
|||
|
||||
# Load config
|
||||
. ${HOME}/ayo.conf
|
||||
. functions.sh
|
||||
|
||||
# TODO: write log for echoes with >>>
|
||||
|
||||
|
@ -12,16 +13,7 @@ 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"
|
||||
}
|
||||
notesSync
|
||||
else
|
||||
{
|
||||
read -p "Enter file name: " title
|
||||
|
@ -44,6 +36,8 @@ else
|
|||
else
|
||||
vim "$full_path"
|
||||
fi
|
||||
|
||||
notesSync
|
||||
} || {
|
||||
echo ">>> New note failed"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue