From f557b85709b56b7798276700850afe9ae2b838a5 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Sun, 29 Sep 2013 16:18:56 +0100 Subject: [PATCH] tmux 1.8 changed how run-shell works. Prior to tmux 1.8 all run-shell commands ran in the foreground and we had to detach explicitly. From 1.8 onwards we can use the -b flag to run a command in the background. Ensure we run ktmux_helper in the appropriate way for the available tmux version. --- .profile.d/tmux.bashrc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.profile.d/tmux.bashrc b/.profile.d/tmux.bashrc index abbbff7..2bf7f05 100644 --- a/.profile.d/tmux.bashrc +++ b/.profile.d/tmux.bashrc @@ -5,7 +5,25 @@ 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 -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 -- 2.7.4