I didn't think it was particularly relevant, as the behaviour was
reproducible with the 'tmux split-window -t <n>' command alone, however I
have included below anyway.
Unfortunately the tmux server where I was able to reproduce the problem has
segfaulted, so I might have to put this on ice until I can reproduce it
again.
Regards,
Scott
This is the key binding, for e.g. I would use a sequence like Ctrl-A, N,
node10{1,2,3} <enter>:
# prompt for hosts to connect to, open a new synchronized window with
horizontally split panes for each host, supports brace expansion
bind N command-prompt -p hosts: 'run-shell -b "bash -c \"~/lbin/nw %%
>/dev/null\""'
This is the script, called "nw" for new window:
#!/bin/bash
#
# 2018-07-10 only synchronize panes if there are multiple hosts/panes
#
# use 'ksh -l -c' to invoke profile for push, etc.
# abbreviate host name list by identifying common prefix and comma
separating suffixes
abbreviated=$(
echo "$@" | awk '
{
min=length($1)
for (field=2; field<=NF; field++) { if
(length($field) < min) min=length($field) }
# find longest common prefix
for (prefixlength=1; prefixlength<=min;
prefixlength++) {
prefix=substr($1,1,prefixlength)
for (field=2; field<=NF; field++) { if
($field !~ "^"prefix) {mismatch=1; break } }
if (mismatch) break
}
prefixlength--
printf "%s%s", substr($1,1,prefixlength),
substr($1,prefixlength+1)
for (field=2; field<=NF; field++) { printf
",%s",substr($field,prefixlength+1) }
printf "\n"
}
'
)
synchronize=false
ssh_command=ssh
host=$1
first=$host
shift
[[ -z "$host" ]] && exit
echo opening window to "$ssh_command $host"...
tmux new-window ksh -l -c "$ssh_command $host || ( echo ... ; sleep 3 )" \;
last-window
newwindow=$(tmux list-windows -F '#I #{window_last_flag}' | awk '$2{print
$1}')
echo new window is $newwindow
for host in "$@" ; do
synchronize=true # only if we have multiple hosts
echo splitting window $newwindow to "$ssh_command $host"...
sleep 0.1
tmux split-window -t $newwindow ksh -l -c "$ssh_command $host || (
echo ... ; sleep 3 )" \; select-layout -t $newwindow even-vertical
done
echo switching to window $newwindow
sleep 0.1
tmux select-window -t $newwindow
if $synchronize ; then
echo synchronizing panes
sleep 0.1
tmux set-window-option synchronize-panes
fi
echo "renaming window to $abbreviated (in about 60 seconds)"
(
sleep 60 # delay to allow override - it is set by .profile on
target hosts, after rsync, etc.
tmux rename-window -t $newwindow "$abbreviated"
) &
On Tue, 4 Sep 2018 at 17:10, Nicholas Marriott <[email protected]>
wrote:
> This sounds like a race, but showing your script would be a good start?
>
>
>
>
> On Tue, 4 Sep 2018, 05:16 Scott Rochford, <[email protected]> wrote:
>
>> ... and I can't figure out under which circumstances exactly.
>>
>> I have a script bound to a key which automatically creates a new window
>> and splits and synchronises it (for connecting to multiple hosts in a
>> cluster, for example). I've noticed that occasionally it splits the
>> current window rather than the target window. Usually it's when the
>> current window is already split multiple ways.
>>
>> I can't minimally reproduce it by simply creating a new window split
>> similarly, and then attempting to invoke the problematic command from there
>> - it seems to be specific to an existing window.
>>
>> Any thoughts on how I can collect more useful information to narrow down
>> this bug?
>>
>> Using tmux-2.7 compiled manually on RHEL6 x86_64.
>>
>> Regards,
>>
>> Scott
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "tmux-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
You received this message because you are subscribed to the Google Groups
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.