-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes
executable file
·73 lines (63 loc) · 1.23 KB
/
notes
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
echo "notes."
initdir () {
mkdir -p ~/notes/
rm -r ~/.config/notes.sh > /dev/null 2>&1
mkdir -p ~/.config && mkdir -p ~/.config/notes.sh
echo "$HOME/notes/" >> ~/.config/notes.sh/config
}
customdir () {
read -r -p "custom directory [/home/aadi/notes/]: " customdir
mkdir $customdir
rm ~/.config/notes.sh/config && echo $customdir >> ~/.config/notes.sh/config
}
dir=$(cat $HOME/.config/notes.sh/config)
halp() {
echo "notes.sh is a simple note taking tool."
echo
echo "syntax: notes [-i|n|l|r|h]"
echo "options:"
echo "i init notes.sh config."
echo "n make a new note."
echo "l list all notes."
echo "r delete a note."
echo "c use a custom dir."
echo "h print help."
echo
}
newnote() {
read -r -p "name of your note: " name
touch $dir$name
echo $name >> $dir$name
read -r -p "date: " date
echo $date >> $dir$name
echo "---" >> $dir$name
"${EDITOR:-vim}" $dir$name
}
listnotes() {
echo ""
ls $dir
}
removenote() {
rm $dir$rmname && echo "removed $rmname"
}
while getopts ":hnlicr:" option; do
case $option in
h)
halp
exit;;
n)
newnote;;
l)
listnotes;;
i)
initdir;;
c)
customdir;;
r)
rmname=$OPTARG
removenote;;
\?)
newnote;;
esac
done