aboutsummaryrefslogtreecommitdiff
path: root/src/util/prompt.cc
blob: 08ff7e474b8f361a4b906ab38a770cdefa891698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#include "util/prompt.h"

using namespace std;

namespace ov4
{

    bool emit_prompt = true; /* emit prompt (default) */

    void print_prompt()
    {
        if (emit_prompt) 
        {
            char hostname[MAXLINE];
            gethostname(hostname, MAXLINE);
            char *user = getlogin();

	        cout 
                << make_color((string)name, ov4::color::bright_green) 
                << " "
                << make_color((user != nullptr ? user : "ov4"), ov4::color::bright_blue)
                << make_color("@", ov4::color::bright_blue)
                << make_color(hostname, ov4::color::bright_blue)
                << ":"
                << make_color(get_current_dir(), ov4::color::bright_purple)
                << " " 
                << make_color(get_prompt(), ov4::color::bright_yellow)
                << " " 
                << flush;
	    }
    }

    string get_prompt()
    {
        return (string)((string)(getlogin()) == "root" ? prompt_root : prompt_normal);
    }
}