From b1107e4a5fdb949d695686866ea61cb1c21519be Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Wed, 31 Jul 2024 15:12:03 -0400 Subject: experiments doesn't quite work can't launch top for tty issue need to call bash -i from opposite side to inherit the screen terminal also the COPROC fd is not inherited, wtf? --- twopane.bash | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'twopane.bash') diff --git a/twopane.bash b/twopane.bash index 6e5aeca..59b8d4b 100644 --- a/twopane.bash +++ b/twopane.bash @@ -5,27 +5,52 @@ set -o pipefail shopt -s lastpipe TWOPANE=$(mktemp -d) +export TWOPANE +trap 'rm -r "$TWOPANE"' EXIT STY=twopane.${TWOPANE##*/} SCREENRC=$TWOPANE/screenrc -export TWOPANE cat > "$SCREENRC" <<'.' unbindall escape \0\0 +escape `` caption string '%t' layout new split focus top -screen -ln -t 'output' 0 nc -NUls "$TWOPANE"/socket +screen -ln -t 'output' 0 sh -c 'socat -U STDOUT UNIX-RECV:"$TWOPANE"/socket; screen -X quit' title 'output' focus bottom -resize 4 -# screen -ln -t 'input' 1 bash "$TWOPANE"/bashrc -screen -ln -t 'input' 1 nc -NU "$TWOPANE"/socket +resize 8 +focus top +fit +focus bottom +screen -ln -t 'input' 1 bash "$TWOPANE"/bashrc layout save 0 . + cat > "$TWOPANE"/bashrc <<'.' -coproc nc -NU "$TWOPANE"/socket -bash -i 2>${COPROC[1]} <${COPROC[0]} +set -e +trap "screen -X quit" EXIT +coproc socat -u SYSTEM:"bash -i",pty,ctty,setsid,stderr,cloexec=0 UNIX-SENDTO:"$TWOPANE"/socket +exec 30>&${COPROC[1]} +send() +{ + printf '%s\n' "$*" >&30 +} +sendc() +{ + printf '%s' "$*" >&30 +} +send echo hello world +sendc echo hello +sleep 1 +send world2 +sleep 1 +send top +export -f send sendc +bash -i || true +send echo hello world3 +sleep 1 . screen -c "$SCREENRC" -m -S "$STY" -ln -- cgit v1.2.3