-
Notifications
You must be signed in to change notification settings - Fork 13
/
irc
executable file
·44 lines (35 loc) · 864 Bytes
/
irc
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
#!/usr/bin/env bash
# irc -- attach to my tmux session with the IRC client
. lib.bash || exit
usage() {
echo "Usage: $progname [-f] [-m]"
echo
echo_opt "-f" "allow duplicate attach"
echo_opt "-m" "use Mosh"
}
session=${XDG_SESSION_ID:-${DISPLAY:-${WAYLAND_DISPLAY:-none}}}
lockfile=${XDG_RUNTIME_DIR?}/irc-$session.lock
opt_mosh=0
opt_force=0
while getopts :fms OPT; do
case $OPT in
f) opt_force=1;;
m) opt_mosh=1;;
s) opt_mosh=0;;
*) lib:die_getopts;;
esac
done; shift $((OPTIND-1))
. ~/.config/nullroute.lt/irc.conf || exit
exec {fd}<>"$lockfile"
if (( !opt_force )); then
flock -xn $fd || vdie "already connected from $HOSTNAME/$session"
fi
if (( opt_mosh )); then
export MOSH_TITLE_NOPREFIX=y
mosh "${irc_host?}" -- tmux attach -t irc; r=$?
else
ssh -t "${irc_host?}" "tmux attach -t irc"; r=$?
fi
exec {fd}>&-
hi &> /dev/null &
exit $r