diff --git a/kernel/advanced_cmds/fortune.h b/kernel/advanced_cmds/fortune.h new file mode 100644 index 0000000..2276ee0 --- /dev/null +++ b/kernel/advanced_cmds/fortune.h @@ -0,0 +1,12 @@ +#pragma once +#include "../io.h" +#include "../../lib/rand.h" +#include "../../drivers/display.h" + +void ksh_fortune() { + const char fortunes[3] = {"Pohl's Law: Nothing is so good that somebody, somewhere, will not hate it.", "You either die a smart fella, or live long enough to become a fart smella", "Everyone asked you about your favorite dinosaur as a kid, now, nobody cares", "Even stock traders want to arrest hatred", "Generically, fiery liquors that produce madness in total abstainers.", "Our remedies oft in ourselves do lie,? Which we ascribe to heaven.", "One of the most conspicuous qualities of a man in security."}; + kprintc('\n'); + int RandIndex = rand() % sizeof(fortunes); + kprints(arrayNum[RandIndex]); + kprintc('\n'); +} diff --git a/kernel/ksh.h b/kernel/ksh.h index 833aa7c..3617cf9 100644 --- a/kernel/ksh.h +++ b/kernel/ksh.h @@ -16,6 +16,7 @@ char* theme; #include "advanced_cmds/write_to_file.h" #include "advanced_cmds/make_file.h" #include "advanced_cmds/remove_file.h" +#include "advanced_cmds/fortune.h" #define KSH_OK 0x0 #define KSH_EXIT 0x1 @@ -42,7 +43,8 @@ byte ksh_interpret(char* command) "mk", "rm", "in", - "to" + "to", + "fortune" }; for (int i = 0; i < sizeof(ListOfOwnCmds) / sizeof(char*); i++) { @@ -74,6 +76,7 @@ byte ksh_interpret(char* command) kprints("mk create new file\n"); kprints("rm delete file\n"); kprints("in read file content\n"); + kprints("fortune fortune cookie\n"); break; case 2: kprints("Hello World!\n"); @@ -140,6 +143,9 @@ byte ksh_interpret(char* command) case 18: ksh_write_to_file(); break; + case 19: + ksh_fortune(); + break; default: kprints(KERNEL_INFO_SHELL_UNKNOWN_COMMAND); break;