feat(journal): new note command
This commit is contained in:
parent
abf6201ce1
commit
098f12f497
2 changed files with 47 additions and 16 deletions
10
ayo.sh
10
ayo.sh
|
@ -1,9 +1,17 @@
|
||||||
#! /usr/bin/bash
|
#! /usr/bin/bash
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
js)
|
## SHORTCUTS
|
||||||
|
|
||||||
|
js) # js - journal sync
|
||||||
. ${HOME}/Projects/scripts/journal.sh sync
|
. ${HOME}/Projects/scripts/journal.sh sync
|
||||||
;;
|
;;
|
||||||
|
jn) # js - journal note
|
||||||
|
. ${HOME}/Projects/scripts/journal.sh note
|
||||||
|
;;
|
||||||
|
|
||||||
|
## SCRIPTS
|
||||||
|
|
||||||
j | journal)
|
j | journal)
|
||||||
. ${HOME}/Projects/scripts/journal.sh $2 $3 $4 $5
|
. ${HOME}/Projects/scripts/journal.sh $2 $3 $4 $5
|
||||||
;;
|
;;
|
||||||
|
|
33
journal.sh
33
journal.sh
|
@ -20,7 +20,30 @@ if [ "$1" = "sync" ]; then
|
||||||
# Report; TODO: write log
|
# Report; TODO: write log
|
||||||
echo ">>> Sync failed"
|
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
|
else
|
||||||
|
{
|
||||||
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}"
|
||||||
|
|
||||||
|
@ -28,14 +51,14 @@ else
|
||||||
if ! test -f "$full_path"; then
|
if ! test -f "$full_path"; then
|
||||||
install -Dv /dev/null "$full_path"
|
install -Dv /dev/null "$full_path"
|
||||||
# TODO: update to correct heading from old entries
|
# TODO: update to correct heading from old entries
|
||||||
# Jun 17, 2025, Tue 10:24 PM
|
date_heading=$(date +'%b %d, %Y, %a %r')
|
||||||
heading=$(date +'%b %d, %Y, %a %r')
|
echo $date_heading > "$full_path"
|
||||||
echo $heading > "$full_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Open in editor
|
# Open in editor
|
||||||
typora "$full_path"
|
vim "$full_path"
|
||||||
|
} || {
|
||||||
# Report; TODO: write log
|
# Report; TODO: write log
|
||||||
echo ">>> " $full_path
|
echo ">>> " $full_path
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue