update get_prompt()
This commit is contained in:
parent
4dfa13221c
commit
6fe039c3e7
@ -4,13 +4,13 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "../../lib/bozolib/bozolib.h"
|
#include "../../lib/bozolib/bozolib.h"
|
||||||
|
#include "../../lib/bozolib/src/str/str.h"
|
||||||
#include "../env/env.h"
|
#include "../env/env.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
static char* get_prompt(lst** env)
|
static char* get_prompt(lst** env)
|
||||||
{
|
{
|
||||||
char* out;
|
char* out;
|
||||||
int size;
|
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
if (getcwd(cwd, sizeof(cwd)) == NULL)
|
if (getcwd(cwd, sizeof(cwd)) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -32,15 +32,11 @@ static char* get_prompt(lst** env)
|
|||||||
strcpy(cwd, "~");
|
strcpy(cwd, "~");
|
||||||
strcat(cwd, cwd + strlen(home));
|
strcat(cwd, cwd + strlen(home));
|
||||||
}
|
}
|
||||||
size = strlen(user) + strlen(hostname_buff) + strlen(cwd) + 9;
|
out = str_merger(8, "[", user, "@", hostname_buff, "]", " > ", cwd, " ");
|
||||||
out = malloc(size*sizeof(char));
|
|
||||||
if(out == NULL)
|
|
||||||
return NULL;
|
|
||||||
sprintf(out, "[%s@%s] > %s ",user, hostname_buff, cwd);
|
|
||||||
if (strcmp(user, "root") == 0)
|
if (strcmp(user, "root") == 0)
|
||||||
strcat(out, "# ");
|
out = str_merger(2, out, "# ");
|
||||||
else
|
else
|
||||||
strcat(out, "$ ");
|
out = str_merger(2, out, "$ ");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user