-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmux.py
executable file
·88 lines (84 loc) · 1.58 KB
/
tmux.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
import os
import random
import subprocess
gen_name_random = [
"admiring",
"adoring",
"albattani",
"agitated",
"amazing",
"angry",
"awesome",
"backstabbing",
"berserk",
"big",
"boring",
"clever",
"cocky",
"compassionate",
"condescending",
"cranky",
"desperate",
"determined",
"distracted",
"dreamy",
"drunk",
"ecstatic",
"elated",
"elegant",
"evil",
"fervent",
"focused",
"furious",
"gigantic",
"gloomy",
"goofy",
"grave",
"happy",
"high",
"hopeful",
"hungry",
"insane",
"jolly",
"jovial",
"kickass",
"lonely",
"loving",
"mad",
"modest",
"naughty",
"nauseous",
"nostalgic",
"pedantic",
"pensive",
"prickly",
"reverent",
"romantic",
"sad",
"serene",
"sharp",
"sick",
"silly",
"sleepy",
"small",
"stoic",
"stupefied",
"suspicious",
"tender",
"thirsty",
"tiny",
"trusting"
]
assign_random_name = (random.choice(gen_name_random))
attached_session = ['tmux', 'list-sessions', '-F', '#{session_attached}']
new_session = 'tmux new -s %s' % assign_random_name
reattach_session = 'tmux attach'
get_session_number = subprocess.Popen(attached_session, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
store_session_number = get_session_number.stdout.read().strip().decode("utf-8")
if store_session_number == "1":
os.system(new_session)
elif store_session_number == "0":
os.system(reattach_session)
else:
os.system(new_session)