summaryrefslogtreecommitdiff
path: root/twopane.bash
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2024-07-31 16:08:47 -0400
committerAndrew Cady <d@jerkface.net>2024-07-31 16:08:47 -0400
commita3a4b4f1af814bb1f50afc0677b09bb1f955d0e0 (patch)
treee2313fbc7f04fc3a76dbf84737cd4bbef353c976 /twopane.bash
parentf348782c30ebf9550befe0d5cf378e5a9a942c1c (diff)
this fuckin works
Diffstat (limited to 'twopane.bash')
-rw-r--r--twopane.bash46
1 files changed, 21 insertions, 25 deletions
diff --git a/twopane.bash b/twopane.bash
index b40f248..2b30a3b 100644
--- a/twopane.bash
+++ b/twopane.bash
@@ -4,8 +4,14 @@ set -f
4set -o pipefail 4set -o pipefail
5shopt -s lastpipe 5shopt -s lastpipe
6 6
7BOT_SIZE=8
8BOT_TITLE=input
9BOT_CMD='PS1="$BOT_TITLE\$ " bash --noprofile --norc -i'
10TOP_CMD='PS1="$TOP_TITLE\$ " bash --noprofile --norc -i; screen -X quit'
11TOP_TITLE=output
12
7TWOPANE=$(mktemp -d) 13TWOPANE=$(mktemp -d)
8export TWOPANE 14export TWOPANE TOP_CMD BOT_CMD TOP_TITLE BOT_TITLE BOT_SIZE
9trap 'rm -r "$TWOPANE"' EXIT 15trap 'rm -r "$TWOPANE"' EXIT
10STY=twopane.${TWOPANE##*/} 16STY=twopane.${TWOPANE##*/}
11SCREENRC=$TWOPANE/screenrc 17SCREENRC=$TWOPANE/screenrc
@@ -16,43 +22,33 @@ escape ``
16caption string '%t' 22caption string '%t'
17layout new 23layout new
18split 24split
19focus top
20screen -ln -t 'output' bash -i
21exec :!:| socat -U STDOUT UNIX-RECV:"$TWOPANE"/socket
22title 'output'
23focus bottom 25focus bottom
24resize 8 26resize $BOT_SIZE
27screen -ln -t "$BOT_TITLE" 1 bash "$TWOPANE"/bashrc
25focus top 28focus top
26fit 29screen -ln -t "$TOP_TITLE" sh -c "$TOP_CMD"
30exec :!:| socat -u UNIX-RECV:"$TWOPANE"/socket STDOUT
31title 'output'
27focus bottom 32focus bottom
28screen -ln -t 'input' 1 bash "$TWOPANE"/bashrc
29layout save 0 33layout save 0
30. 34.
31 35
32cat > "$TWOPANE"/bashrc <<'.' 36cat > "$TWOPANE"/bashrc <<'.'
33set -e
34trap "screen -X quit" EXIT 37trap "screen -X quit" EXIT
35coproc socat -u STDIN,cloexec=0 UNIX-SENDTO:"$TWOPANE"/socket 38sendp()
36exec 30>&${COPROC[1]}
37send()
38{ 39{
39 printf '%s\n' "$*" >&30 40 socat -u STDIN UNIX-SENDTO:"$TWOPANE"/socket
40} 41}
41sendc() 42sendc()
42{ 43{
43 printf '%s' "$*" >&30 44 printf '%s' "$*" | sendp
45}
46send()
47{
48 sendc "$*"$'\n'
44} 49}
45send echo hello world 50export -f send sendc sendp
46sendc echo hello 51eval "$BOT_CMD"
47sleep 1
48send world2
49sleep 1
50send top
51export -f send sendc
52bash -i || true
53sendc q
54send echo hello world3
55sleep 1
56. 52.
57 53
58screen -c "$SCREENRC" -m -S "$STY" -ln 54screen -c "$SCREENRC" -m -S "$STY" -ln