sophuwu.site > bashprompt
removed temp files and have a bash var file
make the escape sequences work yay
sophuwu sophie@sophuwu.site
Mon, 09 Oct 2023 12:25:42 +0200
commit

d2e581778f0a67f6cc389285371727e62b422cd4

parent

43f072e8186b31f2600084e4287c4b888b862ccb

8 files changed, 9 insertions(+), 22 deletions(-)

jump to
D CMakeLists.txt

@@ -1,6 +0,0 @@

-cmake_minimum_required(VERSION 3.16) -project(bashprompt) - -set(CMAKE_CXX_STANDARD 17) - -add_executable(bashprompt main.cpp)
A bashvar

@@ -0,0 +1,1 @@

+PROMPT_COMMAND='` bashprompt ` ; PS1=` bashprompt "!" ` '
D enablebash

@@ -1,2 +0,0 @@

-PS1='\r `bashprompt "!"` \0' -export PROMPT_COMMAND='`bashprompt`'
M main.cppmain.cpp

@@ -60,7 +60,7 @@ std::srand(std::time(nullptr)*count);

std::string path = std::filesystem::current_path(); return std::to_string(count).append(" ") .append(emotes[std::rand() % 12]).append(" ") - .append(path.substr(path.find_last_of('/')+1)).append("$"); + .append(path.substr(path.find_last_of('/')+1)); }

@@ -77,38 +77,36 @@ if (argc > 1 && argv[1][0]=='h') {

printf("To use this program\n"); printf("add the following lines to your .bashrc:\n"); printf("export PROMPT_COMMAND='`%s`'\n", argv[0]); - printf("PS1='`%s \"!\"`'\n", argv[0]); + printf("PS1=`%s \"!\"`\n", argv[0]); return 0; } rainbow r; int count = 0; int err = getAllEnvs(r, count); if (argc > 1 && argv[1][0] == '!') { - std::string outbuff = "\033[38;2;255;0;180m<3\033[0m "; std::string prompt = makePrompt(count); if (err) { - outbuff.append(prompt); - printf("%s", outbuff.c_str()); + printf("%s \\$[] ", prompt.c_str()); return 0; } + std::string outbuff = "\\[\\e[38;2;255;0;180m\\]<3\\[\\e[0m\\] "; // r.print2d(prompt, 40+count%20-count%13+count%7); r.s=5.0*255.0/(double)(40+count%20-count%13+count%7); int i = 0; for (; i < prompt.length(); i++) { - outbuff.append("\033[38;2;") - .append(r.c.str()).append("m") + outbuff.append("\\[\\e[38;2;") + .append(r.c.str()).append("m\\]") .append(prompt.substr(i, 1)) - .append("\033[0m"); + .append("\\[\\e[0m\\]"); r.next(); } - outbuff.append(" "); + outbuff.append(" \\[\\e[38;2;255;0;180m\\]\\\\$\\[\\e[0m\\] "); for (const char* c = outbuff.c_str(); *c; c++) { if (*c == 10 || *c == 13 || *c == 0) continue; fwrite(c, 1, 1, stdout); } return 0; } - int i = 0; if (argc > 1 && argv[1][0] == 's') r.init(15+stoi(argv[1], i)); if (err || !(int)r.s || (!(int)r.c.r && !(int)r.c.g && !(int)r.c.b))
D pcmd.txt

@@ -1,1 +0,0 @@

-`bashprompt`
D prompt.txt

@@ -1,1 +0,0 @@

-<3 375 :) bashpromt$
D ps1.txt

@@ -1,1 +0,0 @@

-`bashprompt "!"`PS1=`bashprompt "!"` $(printf "\e[3X")
D ps2.txt

@@ -1,1 +0,0 @@

-$( printf "\\r` bashprompt "!" `\\e7 \\e8" )