summaryrefslogtreecommitdiff
path: root/bin/ii
blob: d3176ad8ced92266e7ed581bda53a8073dbd0cc7 (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
#!/bin/bash

if [ "$(hostname -f)" = "athena.silentflame.com" ]; then
    # start irssi under tmux if it's not running
    # we used to use dtach, but then dtach+mosh started to mispaint irssi
    if ! tmux list-sessions | grep -Eq "^irssi:"; then
	# If there's no root tmux daemon yet, ensure it has a normal PATH.
	if ! tmux info >/dev/null 2>&1; then
	    source /etc/profile
	    source $HOME/.shenv
	fi
        # if I change timezone, patch the following line on 'athena'
        # branch of dotfiles repo; e.g. `TZ=Asia/Taipei`.  Then in
        # running session, do e.g. /script exec $ENV{'TZ'}='Asia/Taipei';
        SHELL=/bin/bash TZ=MST tmux new-session -d -s irssi irssi
    fi

    # disable the status bar
    tmux set -t irssi status off

    # if we're not at a dumb terminal (so this script can be shoved in a
    # crontab), try to attach what we (maybe) just made.
    # following line is a bashism
    if [ -t 1 ]; then
        tmux attach-session -t irssi
    fi
else
    # on a workstation, get connected to athena
    mosh athena /home/spwhitton/src/dotfiles/bin/ii
fi