# profile-requires: screen.bashrc
# XXX: Use a module.
-tmux=$(PATH=$PATH:/comm/tmux/stable/bin find_working tmux 2>/dev/null)
+krenew=$(find_working krenew 2>/dev/null)
+tmux=$(find_working tmux 2>/dev/null)
if [ $? = 0 ]; then
- alias session="bigtmux $tmux has -t session 2>/dev/null && tmux attach -t session || ktmux -T $tmux -s session"
+ alias session="bigtmux $tmux has -t session 2>/dev/null && tmux attach -t session || ktmux -R $krenew -T $tmux -s session"
if [ -n "$TMUX" ]; then
- $tmux run-shell ktmux_helper ';' detach 2>/dev/null
+ ktmux_args=${TMUX##*,}
+ if [ "$ktmux_args" = "$TMUX" ]; then
+ ktmux_args=
+ else
+ ktmux_args="-s $ktmux_args"
+ fi
+
+ # tmux 1.8 added -b flag to run-shell. Prior to 1.8 we must detach.
+ tmux_version=$($tmux -V)
+ tmux_version=${tmux_version#tmux }
+ tmux_version=${tmux_version//[^0-9]/}
+ tmux_major=${tmux_version%%.*}
+ tmux_minor=${tmux_version#*.}
+ tmux_minor=${tmux_minor%%.*}
+ tmux_version=$((tmux_minor+tmux_major*10))
+ if [ $tmux_version -lt 18 ]; then
+ $tmux run-shell "ktmux_helper $ktmux_args -R $krenew" ';' detach 2>/dev/null
+ else
+ $tmux run-shell -b "ktmux_helper $ktmux_args -R $krenew" 2>/dev/null
+ fi
fi
fi
+unset krenew tmux tmux_version tmux_major tmux_minor ktmux_args