-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathitermreprint.py
executable file
·45 lines (34 loc) · 1.06 KB
/
itermreprint.py
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
#!/usr/bin/python
# itermreprint.py
# About: This application simulates users inputs on iTerm2 according to a line from an input file, addressed by the first file's line, and does not increments it for further uses.
# Author: Rafael Lopes <[email protected]>
# Author: Rafael Lopes <[email protected]>
# Version: 1.0
from sys import stdout, argv
from time import sleep
from random import uniform
def main():
path=str(argv[1])
#print path
f = open(path,'r')
lines = f.readlines()
f.close()
head = int(lines[0])
#print head
#nexthead = head + 1
line = lines[head-1]
line = str(line)
# if you see ^^^ remove everything after, including new line
if "^^^" in line:
line = line[:line.find("^^^")]
for char in line:
stdout.write(char)
stdout.flush()
sleep(uniform(0.01, 0.08))
#sys.stdout.write(lines[head])
#lines[0] = lines[0].replace(str(lines[0]), str(nexthead) + "\n")
#with open(path, 'w') as fout:
# for line in lines:
# fout.write(line)
if __name__ == "__main__":
main()