aboutsummaryrefslogtreecommitdiff
path: root/src/util/prompt.cc
blob: 977cb0b83f678464f9c9bf5c68586d115926d6f2 (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

#include "util/prompt.h"

namespace ov4
{
    using namespace std;

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

    void print_prompt()
    {
        if (emit_prompt) 
        {
            char buffer[hostname_size];
            gethostname(buffer, hostname_size);
	        cout 
                << name 
                << " "
                << getlogin()
                << "@"
                << buffer
                << ":"
                << get_current_dir() 
                << " " 
                << get_prompt() 
                << " " 
                << flush;
	    }
    }

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