Zaktualizuj 'microshell/microshell.c'

This commit is contained in:
Krystian Rzepa 2018-12-19 18:28:05 +00:00
parent 52f7668822
commit e325426320

View File

@ -7,6 +7,14 @@
#define space " \n" #define space " \n"
#define max_c 500 #define max_c 500
#define BRIGHT 1
#define RED 31
#define GREEN 32
#define YELLOW 33
#define BLUE 34
#define PINK 35
#define CYAN 36
#define WHITE 37
int help() { int help() {
printf ("microshell v1.0. © 2018 Krystian Rzepa\n"); printf ("microshell v1.0. © 2018 Krystian Rzepa\n");
@ -38,11 +46,22 @@ int main()
char line[max_c], lend[max_c], * commands[max_c], ** command; char line[max_c], lend[max_c], * commands[max_c], ** command;
void domyslny_kolor()
{
printf("%c[%dm",0x1B,0);
}
while (1) { while (1) {
gethostname(hostName, 99); gethostname(hostName, 99);
getcwd(cwd, 999); getcwd(cwd, 999);
printf("%s@%s %s $ ", pw->pw_name, hostName, cwd); printf("%c[%dm%s",0x1B, YELLOW, pw->pw_name);
domyslny_kolor();
printf("@");
printf("%c[%dm%s ",0x1B, YELLOW, hostName);
printf("%c[%dm%s",0x1B, CYAN, cwd);
printf("%c[%dm $ ",0x1B, GREEN);
domyslny_kolor();
fflush(stdout); fflush(stdout);
if (fgets(line, max_c, stdin )) { if (fgets(line, max_c, stdin )) {