--- /dev/null
+SHELL = /bin/zsh
+PROG = todo
+PREFIX ?= /home/huck/.local/bin
+TODOLIST = /home/huck/info/notes/todo
+
+install : main.c input.c file.c
+ gcc *.c -o '$(PREFIX)/$(PROG)'
+
+header : todo.h
+ gcc *.h
+
+clean :
+ rm *.gch
+ rm "$(PREFIX)/$(PROG)"
+ cp $(TODOLIST).md $(TODOLIST)
+
+test :
+ todo
+ todo -n something
+ todo -d stuff to do now
+ todo -ns stuff to do
+ todo -ds stuff to do
--- /dev/null
+#include "todo.h"
+
+#define TODOLIST "/home/huck/info/notes/todo"
+
+extern char *note;
+
+enum color {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
+
+FILE *fp;
+
+void add(void){
+ fp = fopen(TODOLIST, "a");
+ if (fp != NULL){
+ fputs(strcat(note,"\n"),fp);
+ fclose(fp);
+ }
+}
+
+void rem(void){
+ char *s = malloc(MAXLINE * sizeof(char));
+ FILE *tmp = fopen("temp", "w");
+
+ fp = fopen(TODOLIST, "r");
+
+
+ while (fgets(s, MAXLINE, fp) != NULL){
+ s[strlen(s) - 1] = 0;
+ if (strcmp(note, s) != 0){
+ fputs(strcat(s,"\n"),tmp);
+ }
+ }
+
+ fclose(fp);
+ fclose(tmp);
+
+ remove (TODOLIST);
+ rename("temp", TODOLIST);
+
+ free(s);
+}
+
+void show(void){
+ char *c;
+
+ c = (char *) malloc(MAXLINE * sizeof(int));
+
+ fp = fopen(TODOLIST,"r");
+ while (fgets(c, MAXLINE, fp) != NULL )
+ printf("\t\t\033[1;35m*\033[0m %s", c);
+ fclose(fp);
+ free(c);
+}
+
+int listcheck(void){
+ char *s;
+
+ fp = fopen(TODOLIST, "r");
+ s = (char *) malloc(MAXLINE * sizeof(char));
+
+ while (fgets(s, MAXLINE, fp) != NULL){
+ s[strlen(s) - 1] = 0;
+ if (strcmp(note, s) == 0){
+ free(s);
+ return 1;
+ }
+ }
+ free(s);
+ return 0;
+}
--- /dev/null
+#include "todo.h"
+
+extern char *note, *o;
+
+void getnote(int n, char *arg[]){
+ char *s = malloc(MAXLINE * sizeof(char));
+
+ while(--n > 0){
+ if ((*++arg)[0] != '-'){
+ strcat(s, *arg);
+ strcat(s, (n > 1) ? " " : "");
+ }
+ }
+ strcpy(note, s);
+ free(s);
+}
+
+void getopt(int n, char *arg[]){
+ char *c;
+
+ if (n == 1){
+ o = "s";
+ }
+
+ while (--n > 0 && (*++arg)[0] == '-'){
+ if (strlen(*arg) <= 3){
+ c = malloc(strlen(*arg) * sizeof(char));
+ c = *arg;
+ strcat(o,(strchr(c, 'd')) ? "d" : "n");
+ if (strchr(c,'s') != NULL){
+ strcat(o,"s");
+ }
+ free(c);
+ } else {
+ printf("\033[31mToo many options\033[0m: %s\n\tUse -h for help", *arg);
+ }
+ }
+
+ if (strlen(o) == 0){
+ if (listcheck() == 0)
+ o = "n";
+ else
+ o = "d";
+ }
+}
+
+
--- /dev/null
+#include "todo.h"
+
+char *note, *o;
+
+int main(int argc, char *argv[]){
+ char op;
+ int length,i;
+ note = (char *) malloc(MAXLINE * sizeof(char));
+ o = (char *) malloc (3 * sizeof(char));
+
+ getnote(argc, argv);
+ length = strlen(note)+1;
+ getopt(argc, argv);
+
+ for (i = 0; i < strlen(o); i++)
+ switch (o[i]) {
+ case 'n':
+ if (listcheck() == 0){
+ add();
+ printf("\033[32mAdded to list\033[0m: %s\n", note);
+ } else {
+ printf("\033[33mAlready on list\033[0m: %s\nRemove from list? (y/\033[1mn\033[0m): ", note);
+ if (getchar() == 'y')
+ rem();
+ }
+ break;
+ case 'd':
+ if (listcheck() == 1) {
+ rem();
+ printf("\033[36mRemoved from list\033[0m: %s\n", note);
+ } else {
+ printf("\033[31mNot on list\033[0m: %s\nAdd to list? (y/\033[1mn\033[0m): ", note);
+ if (getchar() == 'y')
+ add();
+ }
+ break;
+ case 's':
+ printf("\n\tTODO LIST:\n");
+ show();
+ break;
+ }
+ free(note);
+ return 0;
+}
+
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#define MAXLINE 1000
+
+void getnote(int, char *[]);
+void getopt(int, char *[]);
+void add(void);
+void rem(void);
+void show(void);
+int listcheck(void);
+