diff options
Diffstat (limited to 'twopane.bash')
-rw-r--r-- | twopane.bash | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/twopane.bash b/twopane.bash index 5ba1264..876fc50 100644 --- a/twopane.bash +++ b/twopane.bash | |||
@@ -33,14 +33,14 @@ layout new | |||
33 | split | 33 | split |
34 | focus bottom | 34 | focus bottom |
35 | resize $BOT_SIZE | 35 | resize $BOT_SIZE |
36 | screen -ln -t "$BOT_TITLE" 0 bash --noprofile --rcfile "$TWOPANE"/bashrc -x -i | 36 | screen -ln -t "$BOT_TITLE" 0 bash --noprofile --rcfile "$TWOPANE"/bashrc -i |
37 | 37 | ||
38 | source "$TWOPANE"/screenrc.startpane | 38 | source "$TWOPANE"/screenrc.startpane |
39 | . | 39 | . |
40 | 40 | ||
41 | save_screenrc 'startpane' <<'.' | 41 | save_screenrc 'startpane' <<'.' |
42 | focus top | 42 | focus top |
43 | screen -ln -t "$TOP_TITLE" 1 sh -c "$TOP_CMD; screen -X focus top; screen -X remove" | 43 | screen -ln -t "$TOP_TITLE" 1 sh -c "$TOP_CMD" |
44 | exec :!. socat -u UNIX-RECV:"$TWOPANE"/socket STDOUT | 44 | exec :!. socat -u UNIX-RECV:"$TWOPANE"/socket STDOUT |
45 | title 'output' | 45 | title 'output' |
46 | focus bottom | 46 | focus bottom |
@@ -69,29 +69,32 @@ sendp() | |||
69 | } | 69 | } |
70 | sendc() | 70 | sendc() |
71 | { | 71 | { |
72 | [ "${COPROC[1]}" ] || coproc sendp | ||
72 | printf '%s' "$*" >&${COPROC[1]} | 73 | printf '%s' "$*" >&${COPROC[1]} |
73 | } | 74 | } |
74 | send() | 75 | send() |
75 | { | 76 | { |
77 | [ "${COPROC[1]}" ] || coproc sendp | ||
76 | printf '%s' "$*"$'\n' >&${COPROC[1]} | 78 | printf '%s' "$*"$'\n' >&${COPROC[1]} |
77 | } | 79 | } |
78 | start() | 80 | start() |
79 | { | 81 | { |
80 | while read -r -N1 | 82 | [ "${COPROC[1]}" ] || coproc sendp |
83 | while read -r -N1 </dev/tty | ||
81 | do | 84 | do |
82 | printf '%s' "$REPLY" >&${COPROC[1]} | 85 | [ "${COPROC[1]}" ] || break |
83 | done | 86 | printf '%s' "$REPLY" |
87 | done >&${COPROC[1]} | ||
84 | } | 88 | } |
85 | 89 | ||
86 | save_file bashrc <<. | 90 | save_file bashrc <<. |
87 | set -x | ||
88 | set -f | 91 | set -f |
89 | set -o pipefail | 92 | set -o pipefail |
90 | shopt -s lastpipe | 93 | shopt -s lastpipe |
94 | trap 'COPROC=()' SIGPIPE | ||
91 | trap "screen -X quit" EXIT | 95 | trap "screen -X quit" EXIT |
92 | $(declare -f $TWOPANE_FUNCTION_EXPORTS) | 96 | $(declare -f $TWOPANE_FUNCTION_EXPORTS | sed 's/ COPROC / /') |
93 | export PS1="$BOT_TITLE\$ " | 97 | export PS1="$BOT_TITLE\$ " |
94 | coproc sendp | ||
95 | . | 98 | . |
96 | 99 | ||
97 | main() | 100 | main() |