aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/util/prompt.h1
-rw-r--r--src/util/prompt.cc10
2 files changed, 6 insertions, 5 deletions
diff --git a/include/util/prompt.h b/include/util/prompt.h
index a9eae46..a99e933 100644
--- a/include/util/prompt.h
+++ b/include/util/prompt.h
@@ -9,7 +9,6 @@ namespace ov4
inline constexpr std::string_view prompt_normal = "$";
inline constexpr std::string_view prompt_root = "#";
-inline constexpr size_t hostname_size = 128;
extern bool emit_prompt;
void print_prompt();
diff --git a/src/util/prompt.cc b/src/util/prompt.cc
index 6ba1ea9..08ff7e4 100644
--- a/src/util/prompt.cc
+++ b/src/util/prompt.cc
@@ -11,14 +11,16 @@ namespace ov4
{
if (emit_prompt)
{
- char buffer[hostname_size];
- gethostname(buffer, hostname_size);
+ char hostname[MAXLINE];
+ gethostname(hostname, MAXLINE);
+ char *user = getlogin();
+
cout
<< make_color((string)name, ov4::color::bright_green)
<< " "
- << make_color(getlogin(), ov4::color::bright_blue)
+ << make_color((user != nullptr ? user : "ov4"), ov4::color::bright_blue)
<< make_color("@", ov4::color::bright_blue)
- << make_color(buffer, ov4::color::bright_blue)
+ << make_color(hostname, ov4::color::bright_blue)
<< ":"
<< make_color(get_current_dir(), ov4::color::bright_purple)
<< " "