feat: auto sync for notes & journal
This commit is contained in:
parent
8909dbe41e
commit
5fcf06c7aa
2 changed files with 31 additions and 32 deletions
10
journal.sh
10
journal.sh
|
@ -13,14 +13,13 @@ getopts "t" typora; #check if -t flag is given
|
|||
file_name=$(date +'%m.%d.%Y').md
|
||||
full_path="${journal_dir}/${month_dir}/${file_name}"
|
||||
|
||||
if [ "$1" = "sync" ]; then
|
||||
notesSync
|
||||
elif [ "$1" = "append" ]; then
|
||||
notesSync
|
||||
|
||||
if [ "$1" = "append" ]; then
|
||||
{
|
||||
read -p "Add thought: " thought
|
||||
time=$(date +'%r')
|
||||
echo $'\n'\> \[$time\]$'\n'\> $thought >> "$full_path"
|
||||
notesSync
|
||||
} || {
|
||||
echo ">>> Append failed"
|
||||
}
|
||||
|
@ -40,9 +39,10 @@ else
|
|||
else
|
||||
vim "$full_path"
|
||||
fi
|
||||
notesSync
|
||||
} || {
|
||||
# Report; TODO: write log
|
||||
echo ">>> " $full_path
|
||||
}
|
||||
fi
|
||||
|
||||
notesSync
|
||||
|
|
53
notes.sh
53
notes.sh
|
@ -12,33 +12,32 @@ command=$1
|
|||
|
||||
getopts "t" typora; #check if -t flag is given
|
||||
|
||||
if [ "$1" = "sync" ]; then
|
||||
notesSync
|
||||
else
|
||||
{
|
||||
read -p "Enter file name: " title
|
||||
file_name=$title.md
|
||||
full_path="${notes_dir}/${file_name}"
|
||||
notesSync
|
||||
|
||||
# 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
|
||||
{
|
||||
read -p "Enter file name: " title
|
||||
file_name=$title.md
|
||||
full_path="${notes_dir}/${file_name}"
|
||||
|
||||
# Open in editor
|
||||
if [ "$typora" = "t" ]; then
|
||||
typora "$full_path"
|
||||
else
|
||||
vim "$full_path"
|
||||
fi
|
||||
# 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
|
||||
|
||||
notesSync
|
||||
} || {
|
||||
echo ">>> New note failed"
|
||||
}
|
||||
fi
|
||||
# Open in editor
|
||||
if [ "$typora" = "t" ]; then
|
||||
typora "$full_path"
|
||||
else
|
||||
vim "$full_path"
|
||||
fi
|
||||
|
||||
} || {
|
||||
echo ">>> New note failed"
|
||||
}
|
||||
|
||||
notesSync
|
||||
|
|
Loading…
Reference in a new issue