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
|
||||
. ${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
|
||||
. ${HOME}/Projects/scripts/notes.sh -t $2 $3 $4 $5 $6 $7 $8 $9
|
||||
;;
|
||||
|
||||
gs) # git status
|
||||
. ${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
|
||||
|
||||
function editFile() {
|
||||
notesSync
|
||||
|
||||
# Open in editor
|
||||
if [ "$typora" = "t" ]; then
|
||||
typora "$1"
|
||||
else
|
||||
vim "$1"
|
||||
fi
|
||||
|
||||
notesSync
|
||||
}
|
||||
|
||||
function createNote() {
|
||||
{
|
||||
read -p "Enter file name: " title
|
||||
|
@ -28,22 +41,51 @@ function createNote() {
|
|||
echo $date_heading >> "$full_path"
|
||||
fi
|
||||
|
||||
# Open in editor
|
||||
if [ "$typora" = "t" ]; then
|
||||
typora "$full_path"
|
||||
else
|
||||
vim "$full_path"
|
||||
fi
|
||||
editFile "$full_path"
|
||||
|
||||
} || {
|
||||
echo ">>> New note failed"
|
||||
}
|
||||
}
|
||||
|
||||
if [ "$1" = "list" ]; then
|
||||
find $notes_dir -maxdepth 1 -type f -not -name '*~' -not -name '.gitignore' -printf '%f\n'
|
||||
if [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
||||
files=( $notes_dir/*.md )
|
||||
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
|
||||
break
|
||||
} ||
|
||||
{
|
||||
echo "bad choice"
|
||||
break
|
||||
}
|
||||
done
|
||||
else
|
||||
notesSync
|
||||
createNote
|
||||
fi
|
||||
notesSync
|
||||
|
|
Loading…
Reference in a new issue