feat(notes): new notes management script
This commit is contained in:
parent
1cb64f0cf2
commit
89f23a49b2
3 changed files with 69 additions and 32 deletions
21
ayo.sh
21
ayo.sh
|
@ -4,24 +4,27 @@ case $1 in
|
||||||
## SHORTCUTS
|
## SHORTCUTS
|
||||||
|
|
||||||
js) # js - journal sync
|
js) # js - journal sync
|
||||||
. ${HOME}/Projects/scripts/journal.sh sync
|
. ${HOME}/Projects/scripts/journal.sh sync $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
;;
|
;;
|
||||||
jn) # js - journal note
|
ns) # js - journal sync
|
||||||
. ${HOME}/Projects/scripts/journal.sh note
|
. ${HOME}/Projects/scripts/notes.sh sync $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
;;
|
;;
|
||||||
|
|
||||||
## SCRIPTS
|
## SCRIPTS
|
||||||
|
|
||||||
|
n | notes)
|
||||||
|
. ${HOME}/Projects/scripts/notes.sh $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
|
;;
|
||||||
|
j | journal)
|
||||||
|
. ${HOME}/Projects/scripts/journal.sh $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
|
;;
|
||||||
|
c | config)
|
||||||
|
echo 'Config script in-progress'
|
||||||
|
;;
|
||||||
m | mac)
|
m | mac)
|
||||||
quickemu --vm macos-monterey.conf --width 1920 --height 1080
|
quickemu --vm macos-monterey.conf --width 1920 --height 1080
|
||||||
;;
|
;;
|
||||||
ms)
|
ms)
|
||||||
quickemu --vm macos-monterey.conf --kill
|
quickemu --vm macos-monterey.conf --kill
|
||||||
;;
|
;;
|
||||||
j | journal)
|
|
||||||
. ${HOME}/Projects/scripts/journal.sh $2 $3 $4 $5
|
|
||||||
;;
|
|
||||||
c | config)
|
|
||||||
echo 'Config script in-progress'
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
28
journal.sh
28
journal.sh
|
@ -7,6 +7,8 @@ command=$1
|
||||||
journal_dir="${notes_dir}/Journal"
|
journal_dir="${notes_dir}/Journal"
|
||||||
month_dir=$(date +"%m %b")
|
month_dir=$(date +"%m %b")
|
||||||
|
|
||||||
|
getopts "t" typora; #check if -t flag is given
|
||||||
|
|
||||||
if [ "$1" = "sync" ]; then
|
if [ "$1" = "sync" ]; then
|
||||||
{
|
{
|
||||||
path="${notes_dir}/"
|
path="${notes_dir}/"
|
||||||
|
@ -19,28 +21,6 @@ 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
|
||||||
|
@ -55,7 +35,11 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Open in editor
|
# Open in editor
|
||||||
|
if [ "$typora" = "t" ]; then
|
||||||
|
typora "$full_path"
|
||||||
|
else
|
||||||
vim "$full_path"
|
vim "$full_path"
|
||||||
|
fi
|
||||||
} || {
|
} || {
|
||||||
# Report; TODO: write log
|
# Report; TODO: write log
|
||||||
echo ">>> " $full_path
|
echo ">>> " $full_path
|
||||||
|
|
50
notes.sh
Executable file
50
notes.sh
Executable file
|
@ -0,0 +1,50 @@
|
||||||
|
#! /usr/bin/bash
|
||||||
|
|
||||||
|
## notes management
|
||||||
|
|
||||||
|
# Load config
|
||||||
|
. ${HOME}/ayo.conf
|
||||||
|
|
||||||
|
# TODO: write log for echoes with >>>
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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
|
||||||
|
if [ "$typora" = "t" ]; then
|
||||||
|
typora "$full_path"
|
||||||
|
else
|
||||||
|
vim "$full_path"
|
||||||
|
fi
|
||||||
|
} || {
|
||||||
|
echo ">>> New note failed"
|
||||||
|
}
|
||||||
|
fi
|
Loading…
Reference in a new issue