aboutsummaryrefslogtreecommitdiffstats
path: root/.zshrc-remote
blob: c257774131005f07888c2896c6771e3d7dedaf53 (plain)
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
[[ $TERM != "screen" ]]; then
	tmux has-session 2>/dev/null
	if [[ "$?" != "0" ]]; then
		tmux
	fi

	tmux has-session 2>/dev/null
	if [[ "$?" != "0" ]]; then
		logout
	fi

	{
		while true; do
			tmux has-session 2>/dev/null
			if [[ "$?" != "0" ]]; then
				logout
			fi

			echo ""
			tmux list-sessions

			echo -n "> "
			read -A args
			case "${args[1]}" in
				a)
					if [[ "${args[2]}" != "" ]]; then
						tmux has-session -t "${args[2]}"
						if [[ "$?" == "0" ]]; then
							tmux attach-session -t "${args[2]}"
						fi
					fi
					;;

				k)
					if [[ "${args[2]}" != "" ]]; then
						tmux has-session -t "${args[2]}"
						if [[ "$?" == "0" ]]; then
							tmux kill-session -t "${args[2]}"
						fi
					fi
					;;

				n)
					tmux new-session
					;;

				q)
					break;
					;;

				*)
					;;
			esac

		done
	}

	logout
fi