add user colors based on uid
This commit is contained in:
parent
969257860c
commit
1772a54d75
23
main.c
23
main.c
|
@ -34,8 +34,18 @@
|
|||
|
||||
int fg = C_BLACK;
|
||||
|
||||
int bgUserRoot = C_L_MAGENTA;
|
||||
|
||||
// COLORS FOR USERS UID >= 1000 (UID - 1000 = Index)
|
||||
int bgUsers[1] = {
|
||||
C_L_GREEN // UID 1000
|
||||
};
|
||||
|
||||
// COLOR FOR USERS UID < 1000
|
||||
int bgUserOther = C_L_YELLOW;
|
||||
|
||||
int bgHost = C_L_CYAN;
|
||||
int bgUser = C_L_GREEN;
|
||||
int bgUser;
|
||||
int bgBranch = C_L_GRAY;
|
||||
int bgEnd = C_CYAN;
|
||||
int bgFolder[] = { C_WHITE, C_CYAN };
|
||||
|
@ -78,12 +88,15 @@ int main(void) {
|
|||
fclose(fp);
|
||||
|
||||
|
||||
|
||||
if (strcmp(username_buf, "root") == 0) {
|
||||
bgUser = C_L_MAGENTA;
|
||||
uid_t uid = getuid();
|
||||
if (uid == 0) {
|
||||
bgUser = bgUserRoot;
|
||||
} else if (uid >= 1000) {
|
||||
bgUser = bgUsers[uid - 1000];
|
||||
} else {
|
||||
bgUser = bgUserOther;
|
||||
}
|
||||
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
||||
fgcol(C_BLACK);
|
||||
|
|
Reference in New Issue