feat(notes): list notes for opening, removing
This commit is contained in:
parent
ec80a63e7a
commit
2a74eb4c33
2 changed files with 63 additions and 10 deletions
11
ayo.sh
11
ayo.sh
|
@ -9,9 +9,20 @@ case $1 in
|
||||||
jt) # journal using typora
|
jt) # journal using typora
|
||||||
. ${HOME}/Projects/scripts/journal.sh -t $2 $3 $4 $5 $6 $7 $8 $9
|
. ${HOME}/Projects/scripts/journal.sh -t $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
nl) # Notes list
|
||||||
|
. ${HOME}/Projects/scripts/notes.sh list $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
|
;;
|
||||||
|
no) # Notes open
|
||||||
|
. ${HOME}/Projects/scripts/notes.sh open $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
|
;;
|
||||||
|
nr) # Notes remove
|
||||||
|
. ${HOME}/Projects/scripts/notes.sh remove $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
|
;;
|
||||||
nt) # Notes using typora
|
nt) # Notes using typora
|
||||||
. ${HOME}/Projects/scripts/notes.sh -t $2 $3 $4 $5 $6 $7 $8 $9
|
. ${HOME}/Projects/scripts/notes.sh -t $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
;;
|
;;
|
||||||
|
|
||||||
gs) # git status
|
gs) # git status
|
||||||
. ${HOME}/Projects/scripts/git.sh stat $2 $3 $4 $5 $6 $7 $8 $9
|
. ${HOME}/Projects/scripts/git.sh stat $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
;;
|
;;
|
||||||
|
|
62
notes.sh
62
notes.sh
|
@ -12,6 +12,19 @@ command=$1
|
||||||
|
|
||||||
getopts "t" typora; #check if -t flag is given
|
getopts "t" typora; #check if -t flag is given
|
||||||
|
|
||||||
|
function editFile() {
|
||||||
|
notesSync
|
||||||
|
|
||||||
|
# Open in editor
|
||||||
|
if [ "$typora" = "t" ]; then
|
||||||
|
typora "$1"
|
||||||
|
else
|
||||||
|
vim "$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
notesSync
|
||||||
|
}
|
||||||
|
|
||||||
function createNote() {
|
function createNote() {
|
||||||
{
|
{
|
||||||
read -p "Enter file name: " title
|
read -p "Enter file name: " title
|
||||||
|
@ -28,22 +41,51 @@ function createNote() {
|
||||||
echo $date_heading >> "$full_path"
|
echo $date_heading >> "$full_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Open in editor
|
editFile "$full_path"
|
||||||
if [ "$typora" = "t" ]; then
|
|
||||||
typora "$full_path"
|
|
||||||
else
|
|
||||||
vim "$full_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
} || {
|
} || {
|
||||||
echo ">>> New note failed"
|
echo ">>> New note failed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" = "list" ]; then
|
if [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
||||||
find $notes_dir -maxdepth 1 -type f -not -name '*~' -not -name '.gitignore' -printf '%f\n'
|
files=( $notes_dir/*.md )
|
||||||
else
|
index=0
|
||||||
|
for file in "${files[@]##*/}"; do
|
||||||
|
((index++))
|
||||||
|
echo "$index) $file"
|
||||||
|
done
|
||||||
|
elif [ "$1" = "open" ] || [ "$1" = "o" ]; then
|
||||||
|
files=( $notes_dir/*.md )
|
||||||
|
PS3="Open file #: "
|
||||||
|
echo "Please select a file."
|
||||||
|
COLUMNS=0; select file in "${files[@]##*/}"; do
|
||||||
|
{
|
||||||
|
echo "Opening $file"
|
||||||
|
editFile "$file"
|
||||||
|
break
|
||||||
|
} ||
|
||||||
|
{
|
||||||
|
echo "bad choice"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
done
|
||||||
|
elif [ "$1" = "remove" ] || [ "$1" = "rm" ]; then
|
||||||
|
files=( $notes_dir/*.md )
|
||||||
|
PS3="Remove file #: "
|
||||||
|
echo "Please select a file."
|
||||||
|
COLUMNS=0; select file in "${files[@]##*/}"; do
|
||||||
|
{
|
||||||
|
echo "Removing $file"
|
||||||
|
rm "${notes_dir}/${file}"
|
||||||
notesSync
|
notesSync
|
||||||
|
break
|
||||||
|
} ||
|
||||||
|
{
|
||||||
|
echo "bad choice"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
done
|
||||||
|
else
|
||||||
createNote
|
createNote
|
||||||
fi
|
fi
|
||||||
notesSync
|
|
||||||
|
|
Loading…
Reference in a new issue