1
1
import os , animation , termcolor
2
2
import socket
3
3
from rich import print
4
- from rich .console import Console
4
+ from rich .console import Console
5
5
import time
6
6
import datetime
7
7
from colorama import Fore
22
22
date = day + "-" + month + "-" + year
23
23
time = datetime .datetime .now ().strftime ("%H:%M" )
24
24
animation .animate ()
25
+
25
26
while True :
26
- console .print (f"[bold][chartreuse1]{ user } @{ name } [/] [magenta2]UNIX[/] [gold1]~{ '/' + path } [/]\n $[/]" , end = '' )
27
+ console .print (
28
+ f"[bold][chartreuse1]{ user } @{ name } [/] [magenta2]UNIX[/] [gold1]~{ '/' + path } [/]\n $[/]" ,
29
+ end = "" ,
30
+ )
27
31
command = input (" " )
28
32
if command .startswith ("touch" ):
29
33
file = command .split ()
52
56
table .add_column ("Name" , style = "dark_slate_gray1" )
53
57
table .add_row ("-a----" , f"{ str (date )} \t { str (time )} " , "" , file [1 ])
54
58
console .print (table )
55
-
59
+
56
60
if command == commands [2 ]:
57
61
listDir = os .listdir ()
58
62
for i in listDir :
59
63
ifDir = os .path .isdir (i )
60
64
if ifDir :
61
65
index = listDir .index (i )
62
66
listDir [index ] = termcolor .colored (f"{ listDir [index ]} /" , "green" )
63
- else : console .print ("unix: mkdir: file doesn't exist" )
64
- print (' ' .join (listDir ))
65
-
67
+ else :
68
+ console .print ("unix: mkdir: file doesn't exist" )
69
+ print (" " .join (listDir ))
70
+
66
71
if command .startswith ("cat" ):
67
72
file = command .split ()
68
73
with open (file [1 ], "r" ) as f :
72
77
if command .startswith ("cp" ):
73
78
file = command .split ()
74
79
length = file .__len__ ()
75
- if length == 1 : console .print ("[magenta2]unix: [gold1]cp: missing file operand" )
76
- if length == 2 : console .print ("[magenta2]unix: [gold1]cp: missing file to copy content" )
80
+ if length == 1 :
81
+ console .print ("[magenta2]unix: [gold1]cp: missing file operand" )
82
+ if length == 2 :
83
+ console .print ("[magenta2]unix: [gold1]cp: missing file to copy content" )
77
84
else :
78
85
with open (file [1 ], "r" ) as f :
79
86
content = f .read ()
80
- with open (file [2 ], 'a' ) as q :
87
+ with open (file [2 ], "a" ) as q :
81
88
q .write (f"\n { content } " )
82
89
83
90
if command .startswith ("del" ):
84
91
file = command .split ()
85
92
length = file .__len__ ()
86
- if length == 1 : console .print ("[magenta2]unix: [gold1]del: missing file operand" )
87
- else : os .remove (file [1 ])
93
+ if length == 1 :
94
+ console .print ("[magenta2]unix: [gold1]del: missing file operand" )
95
+ else :
96
+ os .remove (file [1 ])
88
97
89
- if command .startswith ('mv' ):
98
+ if command .startswith ("mv" ):
90
99
file = command .split ()
91
100
length = file .__len__ ()
92
- if length == 1 : console .print ("[magenta2]unix: [gold1]mv: missing file operand" )
93
- if length == 2 : console .print ("[magenta2]unix: [gold1]mv: missing file to move content" )
101
+ if length == 1 :
102
+ console .print ("[magenta2]unix: [gold1]mv: missing file operand" )
103
+ if length == 2 :
104
+ console .print ("[magenta2]unix: [gold1]mv: missing file to move content" )
94
105
else :
95
106
try :
96
107
with open (file [1 ], "r" ) as f :
97
108
content = f .read ()
98
- with open (file [2 ], 'a' ) as q :
109
+ with open (file [2 ], "a" ) as q :
99
110
q .write (f"\n { content } " )
100
111
os .remove (file [1 ])
101
- except : ...
112
+ except :
113
+ ...
0 commit comments