refactor: notesSync steps in all scripts
This commit is contained in:
parent
651bd95adb
commit
99b657d15a
4 changed files with 19 additions and 13 deletions
3
ayo.sh
3
ayo.sh
|
@ -23,6 +23,9 @@ case $1 in
|
|||
. ${HOME}/Projects/scripts/tasks.sh done $2 $3 $4 $5 $6 $7 $8 $9
|
||||
;;
|
||||
|
||||
ns) # Notes sync
|
||||
. ${HOME}/Projects/scripts/notes.sh sync
|
||||
;;
|
||||
nl) # Notes list
|
||||
. ${HOME}/Projects/scripts/notes.sh list $2 $3 $4 $5 $6 $7 $8 $9
|
||||
;;
|
||||
|
|
|
@ -40,8 +40,7 @@ if [ "$1" = "append" ]; then
|
|||
{
|
||||
read -p "Add thought: " thought
|
||||
time=$(date +'%r')
|
||||
echo $'\n'\> \[$time\]$'\n'\> $thought >> "$full_path"
|
||||
|
||||
echo $'\n'\> $thought \[$time\] >> "$full_path"
|
||||
} || {
|
||||
echo ">>> Append failed"
|
||||
}
|
||||
|
|
15
notes.sh
15
notes.sh
|
@ -55,12 +55,16 @@ function createNote() {
|
|||
}
|
||||
|
||||
|
||||
## SYNC notes in directory
|
||||
if [ "$1" = "sync" ] || [ "$1" = "s" ]; then
|
||||
notesSync
|
||||
|
||||
## LIST notes in directory
|
||||
if [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
||||
elif [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
||||
echo "ACTIVE NOTES: "
|
||||
notesSync
|
||||
files=( $notes_dir/*.md )
|
||||
index=0
|
||||
notesSync
|
||||
for file in "${files[@]##*/}"; do
|
||||
((index++))
|
||||
echo "$index) $file"
|
||||
|
@ -68,17 +72,16 @@ if [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
|||
|
||||
## OPEN a note from a list
|
||||
elif [ "$1" = "open" ] || [ "$1" = "o" ]; then
|
||||
notesSync
|
||||
files=( $notes_dir/*.md )
|
||||
|
||||
if ! [ "$2" = "" ]; then
|
||||
index=($2-1)
|
||||
open_file=${files[$index]}
|
||||
editFile "$open_file"
|
||||
notesSync
|
||||
else
|
||||
PS3="Open file #: "
|
||||
echo "Please select a file to OPEN."
|
||||
notesSync
|
||||
select file in "${files[@]##*/}"; do
|
||||
{
|
||||
echo "Opening $file"
|
||||
|
@ -94,8 +97,8 @@ elif [ "$1" = "open" ] || [ "$1" = "o" ]; then
|
|||
|
||||
## REMOVE a note from a list
|
||||
elif [ "$1" = "remove" ] || [ "$1" = "rm" ]; then
|
||||
files=( $notes_dir/*.md )
|
||||
notesSync
|
||||
files=( $notes_dir/*.md )
|
||||
|
||||
if ! [ "$2" = "" ]; then
|
||||
index=($2-1)
|
||||
|
@ -122,8 +125,8 @@ elif [ "$1" = "remove" ] || [ "$1" = "rm" ]; then
|
|||
|
||||
## ARCHIVE a note from a list
|
||||
elif [ "$1" = "archive" ] || [ "$1" = "a" ]; then
|
||||
files=( $notes_dir/*.md )
|
||||
notesSync
|
||||
files=( $notes_dir/*.md )
|
||||
|
||||
if ! [ "$2" = "" ]; then
|
||||
index=($2-1)
|
||||
|
|
11
tasks.sh
11
tasks.sh
|
@ -59,9 +59,9 @@ function createtask() {
|
|||
## LIST tasks in directory
|
||||
if [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
||||
echo "ACTIVE TASKS: "
|
||||
notesSync
|
||||
files=( $tasks_dir/*.md )
|
||||
index=0
|
||||
notesSync
|
||||
for file in "${files[@]##*/}"; do
|
||||
((index++))
|
||||
echo "$index) $file"
|
||||
|
@ -69,17 +69,16 @@ if [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
|||
|
||||
## OPEN a task from a list
|
||||
elif [ "$1" = "open" ] || [ "$1" = "o" ]; then
|
||||
notesSync
|
||||
files=( $tasks_dir/*.md )
|
||||
|
||||
if ! [ "$2" = "" ]; then
|
||||
index=($2-1)
|
||||
open_file=${files[$index]}
|
||||
editFile "$open_file"
|
||||
notesSync
|
||||
else
|
||||
PS3="Open file #: "
|
||||
echo "Please select a file to OPEN."
|
||||
notesSync
|
||||
select file in "${files[@]##*/}"; do
|
||||
{
|
||||
echo "Opening $file"
|
||||
|
@ -95,12 +94,14 @@ elif [ "$1" = "open" ] || [ "$1" = "o" ]; then
|
|||
|
||||
## MARK AS DONE a task from a list
|
||||
elif [ "$1" = "done" ] || [ "$1" = "d" ]; then
|
||||
files=( $tasks_dir/*.md )
|
||||
notesSync
|
||||
files=( $tasks_dir/*.md )
|
||||
|
||||
if ! [ "$2" = "" ]; then
|
||||
index=($2-1)
|
||||
done_file=${files[$index]}
|
||||
read -p "Resolution: " resolution
|
||||
echo $resolution >> "$done_file"
|
||||
mv "$done_file" "${tasks_dir}/done/"
|
||||
notesSync
|
||||
else
|
||||
|
@ -121,8 +122,8 @@ elif [ "$1" = "done" ] || [ "$1" = "d" ]; then
|
|||
|
||||
## REMOVE a task from a list
|
||||
elif [ "$1" = "remove" ] || [ "$1" = "rm" ]; then
|
||||
files=( $tasks_dir/*.md )
|
||||
notesSync
|
||||
files=( $tasks_dir/*.md )
|
||||
|
||||
if ! [ "$2" = "" ]; then
|
||||
index=($2-1)
|
||||
|
|
Loading…
Reference in a new issue