diff options
-rw-r--r-- | twopane.bash | 39 |
1 files changed, 32 insertions, 7 deletions
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 | |||
5 | shopt -s lastpipe | 5 | shopt -s lastpipe |
6 | 6 | ||
7 | TWOPANE=$(mktemp -d) | 7 | TWOPANE=$(mktemp -d) |
8 | export TWOPANE | ||
9 | trap 'rm -r "$TWOPANE"' EXIT | ||
8 | STY=twopane.${TWOPANE##*/} | 10 | STY=twopane.${TWOPANE##*/} |
9 | SCREENRC=$TWOPANE/screenrc | 11 | SCREENRC=$TWOPANE/screenrc |
10 | export TWOPANE | ||
11 | cat > "$SCREENRC" <<'.' | 12 | cat > "$SCREENRC" <<'.' |
12 | unbindall | 13 | unbindall |
13 | escape \0\0 | 14 | escape \0\0 |
15 | escape `` | ||
14 | caption string '%t' | 16 | caption string '%t' |
15 | layout new | 17 | layout new |
16 | split | 18 | split |
17 | focus top | 19 | focus top |
18 | screen -ln -t 'output' 0 nc -NUls "$TWOPANE"/socket | 20 | screen -ln -t 'output' 0 sh -c 'socat -U STDOUT UNIX-RECV:"$TWOPANE"/socket; screen -X quit' |
19 | title 'output' | 21 | title 'output' |
20 | focus bottom | 22 | focus bottom |
21 | resize 4 | 23 | resize 8 |
22 | # screen -ln -t 'input' 1 bash "$TWOPANE"/bashrc | 24 | focus top |
23 | screen -ln -t 'input' 1 nc -NU "$TWOPANE"/socket | 25 | fit |
26 | focus bottom | ||
27 | screen -ln -t 'input' 1 bash "$TWOPANE"/bashrc | ||
24 | layout save 0 | 28 | layout save 0 |
25 | . | 29 | . |
30 | |||
26 | cat > "$TWOPANE"/bashrc <<'.' | 31 | cat > "$TWOPANE"/bashrc <<'.' |
27 | coproc nc -NU "$TWOPANE"/socket | 32 | set -e |
28 | bash -i 2>${COPROC[1]} <${COPROC[0]} | 33 | trap "screen -X quit" EXIT |
34 | coproc socat -u SYSTEM:"bash -i",pty,ctty,setsid,stderr,cloexec=0 UNIX-SENDTO:"$TWOPANE"/socket | ||
35 | exec 30>&${COPROC[1]} | ||
36 | send() | ||
37 | { | ||
38 | printf '%s\n' "$*" >&30 | ||
39 | } | ||
40 | sendc() | ||
41 | { | ||
42 | printf '%s' "$*" >&30 | ||
43 | } | ||
44 | send echo hello world | ||
45 | sendc echo hello | ||
46 | sleep 1 | ||
47 | send world2 | ||
48 | sleep 1 | ||
49 | send top | ||
50 | export -f send sendc | ||
51 | bash -i || true | ||
52 | send echo hello world3 | ||
53 | sleep 1 | ||
29 | . | 54 | . |
30 | 55 | ||
31 | screen -c "$SCREENRC" -m -S "$STY" -ln | 56 | screen -c "$SCREENRC" -m -S "$STY" -ln |