-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo
185 lines (177 loc) · 6.66 KB
/
todo
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
#
######### [ Task Daiery [ task manager or simpally todo ] #################
#
#
# █████╗ ███████╗██╗ ██╗██╗███████╗██╗ ██╗ ██╗ ██╗██╗ ██╗███████╗
# ██╔══██╗██╔════╝██║ ██║██║██╔════╝██║ ██║ ██║ ██╔╝██║ ██║██╔════╝
# ███████║███████╗███████║██║███████╗███████║█████╗█████╔╝ ██║ ██║███████╗
# ██╔══██║╚════██║██╔══██║██║╚════██║██╔══██║╚════╝██╔═██╗ ██║ ██║╚════██║
# ██║ ██║███████║██║ ██║██║███████║██║ ██║ ██║ ██╗╚██████╔╝███████║
# ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
#
# Gmail: ashish.kus2408@gmail.com
##################################################################################
#-------------------------------------------------------------------------->[ checking required files. ]
if [ ! -d $HOME/.todo/ ]; then
mkdir $HOME/.todo/
touch $HOME/.todo/TODO
fi
#--------------------------------------------------------------------------> [ Global Variables ]
DEFAULT_LIST=$HOME/.todo/TODO
LIST_DIR=$HOME/.todo/
LISTS=($HOME/.todo/*)
CLIST=$DEFAULT_LIST
# ATTRIBUTES=""
# TXTRESET=" \033[0m"
#--------------------------------------------------------------------------> [ quotes list ]
quotes() {
ARRAY=(
" “Subtracting from your list of priorities is as important as adding to it.” "
" “Each day I will accomplish one thing on my to do list.” "
" “Each day I will accomplish one thing on my to list.” "
" “Life should not be reduced to a to do list.” "
" “Forget your to-do list and create a to-be list.” "
" “Sometimes our stop-doing list needs to be bigger than our to-do list.” "
" “Before you eat the elephant, make sure you know what parts you want to eat.” "
" “To-do list : to-do list!” "
" “Each day I will accomplish one thing on my to do list.” "
" “Each day I will accomplish one thing on my to list.” "
" “Scrum, in simple terms is managing a TO-DO list.” "
" “Where two or three are gathered, a seemingly difficult task gets done.” "
" You Should Use Your Strength To Help Others. -Yuji's Grandfather "
)
echo -e "${ARRAY[ $RANDOM % ${#ARRAY[@]}]}"
}
#--------------------------------------------------------------------------> [ select List ]
ListSelection() {
LISTS_LEN=${#LISTS[@]}
if [ $LISTS_LEN -gt 1 ];
then
for (( i=0 ; i<$LISTS_LEN ; i++));
do
echo "$i) $(basename ${LISTS[$i]})"
done
echo "<ENTER>(default)"
read -p "LIST No. :" choice
if [[ $choice == "" ]]; then
CLIST=$DEFAULT_LIST
elif [[ $choice =~ ^[0-9]+$ ]] && [[ $choice -lt $LISTS_LEN ]] ; then
CLIST=${LISTS[$choice]}
echo " $(basename ${LISTS[$choice]}):"
cat -n $CLIST
else
echo "bad Choice "
ListSelection
fi
else
CLIST=$DEFAULT_LIST
echo "DEFAULT_list"
fi
}
#---------------------------------------------------------------------------> [ add-task ]
add_task(){
read -p "$Green TASK: $Color_Off" TASK
if [[ $TASK == "" ]]; then
return
else
ATTRIBUTES="\033[0;32m "
# echo -e $ATTRIBUTES $TASK $TXTRESET >> $CLIST
echo -e $TASK >> $CLIST
fi
add_task
}
#-------------------------------------------------------------------------->[ add list ]
add_list(){
read -p "LISR_NAME: " NAME
touch $LIST_DIR/$NAME
}
#-------------------------------------------------------------------------->[ DELETE A LIST ]
delete_list(){
LISTS=($HOME/.todo/*)
LISTS_LEN=${#LISTS[@]}
if [ $LISTS_LEN -gt 1 ];
then
for (( i=0 ; i<$LISTS_LEN ; i++));
do
echo "$i) $(basename ${LISTS[$i]})"
done
fi
read -p "RM list no. :" no
rm -rf ${LISTS[$no]}
echo " $(basename ${LISTS[$no]}) DELETED"
}
#-----------------------------------------------------------------------> [ show task ]
show_tasks(){
echo -e "$UYellow$(basename $CLIST: )$Color_Off "
cat -n $CLIST
}
#------------------------------------------------------------------------> [ clear_lilst ] remove all TASKs ]
clear_list(){
read -p "This will remoce all TASK from the list [y/N]:" delete
if [[ $delete == "y" ]] ; then
> $CLIST
else
echo "List not cleared"
fi
}
#------------------------------------------------------------------------> [ DELETE A TASK ]
delete_task(){
read -p "TASK NO. :" taskno
if [[ $taskno != "" ]]; then
sed -i "${taskno}d" $CLIST
else
echo "❌"
fi
}
#------------------------------------------------------------------------> [ Quotes generator ]
#------------------------------------------------------------------------> [ HELP ]
help(){
echo "OPTION: <ENTER> to exit"
echo " a,add : to add task to perticular list by default its TODO."
echo " ls,tasklist: to list all the task in the list chosen"
echo " l,lists : to show all lists you have."
echo " al.addlist : to add new list of task to be done."
echo " d,done : to mark done or simpally remove from list chosen"
echo " c,clear : to clear the terminal"
echo " rml,removelist : to remove a perticular list"
echo " cl,cleanlist : to clear every task from current list"
}
#--------------------------------------------------------------------------> [ ARGUMENT Handeling ]
if [[ $# == 1 ]]; then
if [ $1 == h ] || [ $1 == help ]; then
help
fi
if [ $1 == add ] || [ $1 == a ]; then
add_task
fi
fi
#--------------------------------------------------------------------------> [ swich case ]
show_tasks
while read -p "OPTION\h: " OPTION; do
case $OPTION in
"") quotes
exit
;;
l|lists) ListSelection
;;
a|add) add_task
;;
al|addlist) add_list
;;
rml|removelist) delete_list
;;
ls|tasklist) show_tasks
;;
d|done|--delete) delete_task
;;
c|clear) clear
;;
cl|cleanlist) clear_list
;;
h|help) help
;;
*) echo "<ENTER> to exit OR help to know more"
;;
esac
done