-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.c
More file actions
49 lines (42 loc) · 1009 Bytes
/
Copy pathstart.c
File metadata and controls
49 lines (42 loc) · 1009 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <pwd.h>
#include <limits.h>
#include <string.h>
#include <errno.h>
extern char *user, *home, *t, *args[20];
extern char temp[30], buff[2], cwd[1000], executable[30], buf2[1000], background[10][20], system_name[10];
extern int back, backpid[10], backcount;
void startPrint()
{
int i,j,check,k;
FILE *os;
//get the username
user = getenv("USERNAME");
//get the system name
/*os = popen("lsb_release -i", "r");
i=0;
while (fgets(buff, sizeof(buff), os)!=NULL)
{
temp[i] = buff[0];
i++;
}
pclose(os);
for (j=16;j<i-1;j++)
system_name[j-16] = temp[j];*/
//get hostname
gethostname(system_name,(size_t)sizeof(system_name));
//get the current working directory
t = getcwd(buf2,1000);
t[(int)strlen(t)+1]='\0';
if ((int)strlen(home)<=(int)strlen(t))
{
tilda(t,cwd);
printf("<%s@%s:%s> ",user,system_name,cwd);
}
else
printf("<%s@%s:%s> ",user,system_name,t);
}