Add chroot and job count support.

This commit is contained in:
Érico Rolim 2021-02-22 01:09:07 -03:00
parent e779146066
commit c5cb3277a9
1 changed files with 34 additions and 0 deletions

34
ep.c
View File

@ -30,6 +30,27 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
out = stdout;
char *shell_jobs = NULL;
int chroot = 0;
int c;
while((c = getopt(argc, argv, "cj:")) != -1) {
switch (c) {
case 'c':
chroot = 1;
break;
case 'j':
shell_jobs = optarg;
break;
default:
/* XXX: log error */
return 1;
break;
}
}
if (chroot)
p("[chroot] ");
const char *home = getenv("HOME");
const char *hostname = getenv("HOSTNAME");
@ -82,5 +103,18 @@ int main(int argc, char **argv)
}
}
/* print currently active shell jobs */
if (shell_jobs) {
int n = atoi(shell_jobs);
if (n >= 1) {
p("");
if (n > 1) {
/* jobs emoji is wide */
p(" ");
p(shell_jobs);
}
}
}
p(PROMPT);
}