-
Notifications
You must be signed in to change notification settings - Fork 1
/
tmux-daemon-start
37 lines (30 loc) · 948 Bytes
/
tmux-daemon-start
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
#!/bin/bash
set -u
PATH=$PATH:/usr/local/bin
# set defaults
ipynb_start=${IPYNB_START:-true}
docker_start=${DOCKER_START:-false}
TMUX_SESSION=${TMUX_SESSION:-daemons}
# set up tmux session with "daemons"
# but if at reboot (no tty), wait 10 seconds - it seems to get created,
# then killed
if ! tty -s ; then
sleep 10
fi
function no_window() {
local window="$1"
local -i ec=0
tmux list-windows -t "$TMUX_SESSION" | grep $window &>/dev/null ||
ec=$?
# invert success
test $ec -ne 0
return $?
}
tmux new-session -c /tmp/ -P -d -s "${TMUX_SESSION}" &>/dev/null || true
if $ipynb_start && no_window "jupyter"; then
# test -r ~/bin/useAnaconda && source ~/bin/useAnaconda
tmux new-window -t "${TMUX_SESSION}" -n "jupyter" 'cd ~/wip/ipynb; jupyter notebook --no-browser '
fi
if $docker_start && no_window "docker"; then
tmux new-window -t "${TMUX_SESSION}" -n "docker" 'docker start ; exec bash'
fi