thanks, i figured out this is much more low-level than i thought.
it makes tmux nearly disappear, which is *curious*.
tmux could be replaced by something that doesn't do curses, that only
connects the FDS and muxes them all into this control mode protocol.
it seems just incidental that people are willing to still using tmux
in the background even though 99% of the "terminal emulation" task is
done in iterm. crazy :D
i wanted something similar, but since i already use a tiling window
manager i didn't want any of the window management overhead of using
tmux or using fancy terminal emulators, so i would be really curious
about a much more lightweigt dedicated control-mode server some day,
then i might even implement a client after all :D
in the meantime i hacked together something else that serves my needs
for now, i run this from my window manager depending on window
title/props string (wmii), and this way i can stay inside a remote ssh
context but use my full local window management.
and of course i can re-attach all those windows easily after some reboot.
i'm not bothering about window panes, i demand there's one pane per
window, otherwise it doesn't work. i don't need such deep hierarchies
as my window manager already is complicated enough.
thought of calling it something like tmuxcollapse or so, but tunmux was shorter.
i had a lot of fun today with this. it's a bit like opening a box of
springs when those 100 windows jump out,
#!/bin/sh
newwin(){
$remotecmd tmux new-window -dP -F'#{window_index}' -t $1 || echo error
}
attach_win() {
CLIENTID=$1-$2-"`date +%Y%m%d%H%M%S`"
#rxvt hotfix
yes ' '|sed 300q
# recover scrollback
$remotecmd tmux capture-pane -p -J -S- -E- -t$1:$2
[ -n "$remotecmd" ] && remotecmd="$remotecmd -t"
[ -z "$remotecmd" ] && remotecmd=eval
$remotecmd "tmux new-session -d -t $1 -s $CLIENTID\; \
select-window -t $2\; \
set status off \; \
set-option destroy-unattached\; \
set-hook pane-exited detach-client\; \
setw -g aggressive-resize on\; \
attach-session -t $CLIENTID"
}
error(){
echo error: $*
exit
}
attach_one(){
name=$1
window=$2
export remotecmd
urxvt -name "mux $remotecmd $name $window" -title "mux $remotecmd
$name $window" -e sh -c "tunmux attach_win $name $window"
}
attach_all(){
echo attach_all args: $* remotecmd: $remotecmd
name=$1
[ $name = "s" ] && error cant be named after ssh option
shift
$remotecmd tmux list-windows -t $name 2>/dev/null || (
$remotecmd tmux new-session -d -s $name
$remotecmd tmux set-option -g bell-action current
)
( if [ -z "$1" ]
then
$remotecmd tmux list-windows -F'#I' -t $name
else
while [ -n "$1" ]
do
echo "$1"
shift
done
fi
)|
while read line; do
window=$line
attach_one $name $window &
sleep 0.05
done
}
usage(){
error blablabla
}
echo main args: $* remotecmd: $remotecmd
[ -z "$1" ] && usage
case $1 in
s)
shift;
[ -z "$1" ] && usage
#export remotecmd="ssh $1"
remotecmd="ssh $1"
shift;
[ -z "$1" ] && usage
;;
esac
case $1 in
attach_win)
#only indirectly through attach_all and urxvt
shift
attach_win $*
exit
;;
newwin)
shift
win=`newwin $1`
if [ "$win" = "error" ]
then
attach_all $1
exit
fi
attach_one $1 $win
exit
;;
*)
attach_all $*
exit
esac
>> <
https://groups.google.com/d/msgid/tmux-users/beb865a7-6420-472d-bf88-5daa1cf9f332n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>