-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtnote
More file actions
executable file
·39 lines (34 loc) · 1.01 KB
/
tnote
File metadata and controls
executable file
·39 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
notesdir=$HOME/Dropbox/NOTES/
confirmation="I am sure I want to delete this note"
[[ -d $notesdir ]] && : || mkdir -p $notesdir
getNote(){
echo "$(echo -e "$(ls $notesdir)" | dmenu -l 10 -p "Select Note: ")"
}
while getopts ":c:dor:" arg > /dev/null; do
case $arg in
c)option=c;filename=$OPTARG;;
d)option=d;;
r)option=r;filename=$OPTARG;;
o)option=o;;
esac
done
if [[ $option == c || $option == create ]];then
touch $notesdir$filename
if [[ -e $notesdir$filename && -e $notesdir$filename ]];then
notify-send "Note $filename created" 2> /dev/null
$TERMINAL -e nvim $notesdir$filename &
fi
elif [[ $option == d || $option == delete ]];then
note=$(getNote)
if [[ ! -z $note ]];then
mv $notesdir$note ~/.trash/
[[ ! -e $notesdir$note ]] && notify-send "Note $note deleted."
fi
elif [[ $option == o ]];then
note=$(getNote)
[[ ! -z $note ]] && $TERMINAL -e nvim "$notesdir$note"
elif [[ $option == r ]]; then
read -p "Enter new filename" newfilename
mv $notesdir$filename $notesdir$newfilename
fi