blob: 720381ba802dd86d5fa240b066a4f79e0462ed09 (
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
|
#!/bin/bash
export MOSH_TITLE_NOPREFIX=true
# check if username was supplied
if [ "$1" = "${1/@/}" ]; then
input="$USER@$1"
else
input="$1"
fi
openurxvt ()
{
cmd="$@"
urxvt ++iso14755 ++iso14755_52 -title "$tmuxtitle" -e /bin/sh -c "$cmd" &
}
if [ "$input" = "swhitton@local" ]; then
tmuxtitle="$USER@$(hostname -s)"
launchcmd="tmux attach"
else if [ "$input" = "spw@ma" ]; then
tmuxtitle="$input"
launchcmd="ssh -t $input /usr/pkg/bin/tmux attach"
else
tmuxtitle="$input"
launchcmd="ssh -t $input tmux attach"
fi
fi
currwin=$(xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | cut -d '"' -f 2)
# if we're already looking at tmux, maximise it
if [ "$currwin" = "$tmuxtitle" ]; then
sleep 0.2
wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
else
# We're not looking at tmux. Try to raise it. If that fails, launch it.b
if ! wmctrl -a "$tmuxtitle"; then
openurxvt $launchcmd
fi
fi
|