feat(journal): new subcommand 'append' for one-liner thoughts
This commit is contained in:
parent
c95eb99479
commit
1681745c09
2 changed files with 14 additions and 3 deletions
3
ayo.sh
3
ayo.sh
|
@ -3,6 +3,9 @@
|
|||
case $1 in
|
||||
## SHORTCUTS
|
||||
|
||||
ja) # js - journal append
|
||||
. ${HOME}/Projects/scripts/journal.sh append $2 $3 $4 $5 $6 $7 $8 $9
|
||||
;;
|
||||
js) # js - journal sync
|
||||
. ${HOME}/Projects/scripts/journal.sh sync $2 $3 $4 $5 $6 $7 $8 $9
|
||||
;;
|
||||
|
|
14
journal.sh
14
journal.sh
|
@ -9,6 +9,9 @@ month_dir=$(date +"%m %b")
|
|||
|
||||
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
|
||||
{
|
||||
path="${notes_dir}/"
|
||||
|
@ -21,11 +24,16 @@ if [ "$1" = "sync" ]; then
|
|||
# Report; TODO: write log
|
||||
echo ">>> Sync failed"
|
||||
}
|
||||
elif [ "$1" = "append" ]; then
|
||||
{
|
||||
read -p "Add thought: " thought
|
||||
time=$(date +'%r')
|
||||
echo $'\n'\[$time\] $thought$'\n' >> "$full_path"
|
||||
} || {
|
||||
echo ">>> Append failed"
|
||||
}
|
||||
else
|
||||
{
|
||||
file_name=$(date +'%m.%d.%Y').md
|
||||
full_path="${journal_dir}/${month_dir}/${file_name}"
|
||||
|
||||
# IF Not Exists: create file & echo date
|
||||
if ! test -f "$full_path"; then
|
||||
install -Dv /dev/null "$full_path"
|
||||
|
|
Loading…
Reference in a new issue