if [ $? = 0 ]; then
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 -R $krenew" ';' 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_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
+unset krenew tmux tmux_version tmux_major tmux_minor ktmux_args