delnote: delete a note

This commit is contained in:
dmarakom6 2021-02-08 16:29:47 +02:00
parent b5445be0fb
commit 30aca342d1

40
util/delnote.sh Normal file
View file

@ -0,0 +1,40 @@
:<<'info'
shellnotes - delnote.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
function delnote() {
if [ $# -eq 0 ]; then
echo -n "Enter the name of the note you want to delete: " && read delete
else
delete=$1
fi
if [[ $1 == "-all" ]]; then
dir="$(pwd)"
cd $DEFAULT_PATH
me="$(whoami)"
rm -f *
clear
cd $dir
str="All files deleted from Home/$me/Notes"
underlines=$(echo "$str" | tr -c '\010' '-')
echo "$str\n$underlines"
else
dir="$(pwd)"
cd $DEFAULT_PATH
me="$(whoami)"
if [ -e $delete ]; then
rm $delete
clear
cd $dir
str="Note deleted from Home/$me/Notes"
underlines=$(echo "$str" | tr -c '\010' '-')
echo "$str\n$underlines"
else
echo "No such file."
cd $dir
fi
fi
}