aboutsummaryrefslogtreecommitdiff
path: root/bin/executable_tmcg
blob: 5ebb3cf9cc08543317e3c7854e72286ae5d9c9e3 (plain) (blame)
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
#!/bin/sh

current_session () {
    tty=$(tty)
    for s in $(tmux list-sessions -F '#{session_name}'); do
            tmux list-panes -F '#{pane_tty} #{session_name}' -t "$s"
    done | grep "${tty}" | awk '{print $2}'
}

SESSION=$(current_session)
NEW=1

if [ "x${SESSION}" = "x" ]; then
    SESSION="irc"
    tmux new-session -s "${SESSION}" -d
    NEW=$?
fi

if ! tmux switch -t ${SESSION}:catgirl >/dev/null 2>&1; then
    tmux new-window -c '~' -n catgirl     catgirl libera
    tmux split-window -t ${SESSION}:catgirl -c '~' catgirl oftc
    tmux split-window -t ${SESSION}:catgirl -c '~' catgirl sdf
    tmux split-window -t ${SESSION}:catgirl -c '~' catgirl tilde
    tmux set-option -t ${SESSION}:catgirl remain-on-exit on
    tmux selectl -t ${SESSION}:catgirl tiled
    if test ${NEW} -eq 0; then
        tmux kill-window -t ${SESSION}:0
    fi
fi