sophuwu.site > bashprompt
testing or something
sophuwu sophie@skisiel.com
Wed, 08 May 2024 06:52:44 +0200
commit

abcb7b881a6f5fa886680dd672649b3a8eb695b0

parent

7201758b08992389a50fd8cb7fc93ae664ba8584

1 files changed, 4 insertions(+), 2 deletions(-)

jump to
M src/prompt.cppsrc/prompt.cpp

@@ -63,9 +63,11 @@ }

} str user = envorcmd("USER", "whoami"); + while (user.length()%4 != 0) user += " "; + int size = user.length()/4; str ip = docmd("hostname -I | awk -F '.' ' { for(i=1;i<5;i++){printf(\"%.3d\", $i);}; } ' "); - for (int i = 0; i < user.length(); i++) { - std::cout << "\033[38;5;" << ip.substr((i%4)*3,3) << "m" << user[i] << "\033[0m"; + for (int i = 0; i < 4; i++) { + std::cout << color(user.substr(i*size,size), ip.substr(i*3,3)); } std::cout << std::endl;