58 lines
1 KiB
C
58 lines
1 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <readline/readline.h>
|
|
#include <readline/history.h>
|
|
|
|
#define clear() printf("\033[H\033[J")
|
|
|
|
void init_shell() {
|
|
clear();
|
|
|
|
printf("\n\n\n\n******************************************");
|
|
printf("\n\n\n\t****MY SHELL****");
|
|
printf("\n\n\t-USE AT YOUR OWN RISK-");
|
|
printf("\n\n\n******************************************");
|
|
|
|
char* username = getenv("USER");
|
|
printf("\n\nUSER is: @%s\n", username);
|
|
sleep(1);
|
|
|
|
clear();
|
|
}
|
|
|
|
int take_input(char* str) {
|
|
char* buf;
|
|
|
|
buf = readline("\n>>> ");
|
|
if(strlen(buf) != 0) {
|
|
add_history(buf);
|
|
strcpy(str, buf);
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
void print_dir() {
|
|
char cwd[1024];
|
|
getcwd(cwd, sizeof(cwd));
|
|
printf("\nDir: %s", cwd);
|
|
}
|
|
|
|
def execute(char** parsed) {
|
|
pid_t pid = fork();
|
|
|
|
if (pid == -1) {
|
|
printf("\nFailed forking child..");
|
|
return;
|
|
} else if (pid == 0) {
|
|
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
init_shell();
|
|
}
|