sophuwu.site > bashprompt
testing auto exporting env vars
sophuwu sophie@skisiel.com
Wed, 01 May 2024 21:06:52 +0200
commit

7a17147f8798a36e97a576d95fb354f3ec8bbe4f

parent

6c92911fac71e1e0361318ffd2b795c9161635f1

2 files changed, 7 insertions(+), 7 deletions(-)

jump to
M MakefileMakefile

@@ -1,4 +1,4 @@

-build: +build: src/prompt.cpp mkdir -p build g++ -std=c++17 -o build/bashprompt src/prompt.cpp
M src/prompt.cppsrc/prompt.cpp

@@ -11,15 +11,12 @@ #include <cstdio>

#include <ctime> #include <sys/ioctl.h> #include <unistd.h> -#include <string_view> typedef std::string str; -const std::string emotes[] = -{":)", ":3", ";D",":]", ":D", "xD", -";3", ";)", "=)",":P", ":O", ":b"}; +const str emotes[] = {":)", ":3", ";D",":]", ":D", "xD",";3", ";)", "=)",":P", ":O", ":b"}; -std::string emote() { +str emote() { srand(std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::high_resolution_clock::now().time_since_epoch()).count()); return emotes[rand() % 12];

@@ -67,7 +64,10 @@ return 0;

} int main(int argc, char* argv[]) { - if (getenv("LINENO") == NULL || getenv("USER")==NULL || getenv("PWD")==NULL)return 1; + if (getenv("USER") == NULL)system("export USER=$(whoami)"); + if (getenv("PWD") == NULL)system("export PWD=$(pwd)"); + if (getenv("LINENO") == NULL)system("export LINENO"); + std::string output = ""; if (argc > 1) output += std::string(argv[1]);