-
Notifications
You must be signed in to change notification settings - Fork 0
/
tm.sh
executable file
·110 lines (85 loc) · 2.19 KB
/
tm.sh
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
function showOptions {
echo "1) Create"
echo "2) Close"
echo "3) Attach"
echo "4) Switch"
}
echo ""
echo "Tmux sessions in this machine: "
echo ""
sessions=( $(tmux ls | awk '{print $1}' | tr -d : | column -c 40) )
sessionNumber=0
for i in ${sessions[@]}
do
echo "$sessionNumber) $i"
let sessionNumber=sessionNumber+1
done
echo ""
echo "What do you want to do?: "
showOptions
read -p "?:" option
if [ "$option" == '1' ]; then
read -p "Enter name of the session: " sessionName
tmux new -s $sessionName
fi
if [ "$option" == '2' ]; then
echo ""
echo "Tmux sessions in this machine: "
echo ""
sessions=( $(tmux ls | awk '{print $1}' | tr -d : | column -c 40) )
sessionNumber=0
for i in ${sessions[@]}
do
echo "$sessionNumber) $i"
let sessionNumber=sessionNumber+1
done
echo ""
while true; do
read -p "Which session number would you like to close(-1 to quit):" session
if [ "$session" == '-1' ]; then
exit 0
fi
tmux kill-session -t ${sessions[$session]}
done
fi
if [ "$option" == '3' ]; then
echo ""
echo "Tmux sessions in this machine: "
echo ""
sessions=( $(tmux ls | awk '{print $1}' | tr -d : | column -c 40) )
sessionNumber=0
for i in ${sessions[@]}
do
echo "$sessionNumber) $i"
let sessionNumber=sessionNumber+1
done
echo ""
while true; do
read -p "Which session number would you like to switch(-1 to quit):" session
if [ "$session" == '-1' ]; then
exit 0
fi
tmux attach -t ${sessions[$session]}
done
fi
if [ "$option" == '4' ]; then
echo ""
echo "Tmux sessions in this machine: "
echo ""
sessions=( $(tmux ls | awk '{print $1}' | tr -d : | column -c 40) )
sessionNumber=0
for i in ${sessions[@]}
do
echo "$sessionNumber) $i"
let sessionNumber=sessionNumber+1
done
echo ""
while true; do
read -p "Which session number would you like to switch(-1 to quit):" session
if [ "$session" == '-1' ]; then
exit 0
fi
tmux switch -t ${sessions[$session]}
done
fi