wintext: add tmux support, use in ", ""

Fixes #223.
This commit is contained in:
Russ Cox 2020-01-13 11:04:53 -05:00
parent cc48e73a96
commit fa7fecff33
4 changed files with 19 additions and 20 deletions

View file

@ -2,19 +2,10 @@
. 9.rc . 9.rc
fn text {
if(~ $winid [0-9]*)
9p read acme/$winid/body
if not if(~ $text9term unix!*)
dial -e $text9term </dev/null
if not
status=''
}
PROMPT='[^ ]*[%;$#][ ]+' PROMPT='[^ ]*[%;$#][ ]+'
fn cmds { fn cmds {
text | sed -n 's/^'$PROMPT'([^"])/ \1/p' wintext | sed -n 's/^'$PROMPT'([^"])/ \1/p'
} }
switch($#*) { switch($#*) {

View file

@ -1,6 +1,6 @@
#!/usr/local/plan9/bin/rc #!/usr/local/plan9/bin/rc
cmd = `{" $* | tail -1} cmd = `{quote1 $* | tail -1}
if (~ $#cmd 0) { if (~ $#cmd 0) {
echo no such command found >[1=2] echo no such command found >[1=2]
exit notfound exit notfound

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
case "$winid" in case "$winid" in
[0-9]*) [0-9]*)
@ -12,5 +12,11 @@ unix!*)
exit 0 exit 0
esac esac
case "$TMUX" in
?*)
tmux capture-pane -p
exit 0
esac
echo 'no running window found' 2>&1 echo 'no running window found' 2>&1
exit 1 exit 1

View file

@ -3,17 +3,17 @@
wintext, ", "" \- access text in current window wintext, ", "" \- access text in current window
.ds x \C'"' .ds x \C'"'
.ds xx \C'"'\^\^\^\^\C'"' .ds xx \C'"'\^\^\^\^\C'"'
.ds y \*x\ .ds y \*x\^
.ds yy \*(xx\ .ds yy \*(xx\^
.SH SYNOPSIS .SH SYNOPSIS
.B wintext .B wintext
.br .br
.B \*x\ .B \*y
[ [
.I prefix .I prefix
] ]
.br .br
.B \*(xx\ .B \*(yy
[ [
.I prefix .I prefix
] ]
@ -22,9 +22,11 @@ wintext, ", "" \- access text in current window
prints the text of the current prints the text of the current
.I win .I win
(see (see
.IR acme (1)) .IR acme (1)),
.IR 9term (1),
or or
.IR 9term (1) (Unix's)
.IR tmux (1)
window to standard output. window to standard output.
.PP .PP
.I \*y .I \*y
@ -40,7 +42,7 @@ prints the last command executed.
.I \*(yy .I \*(yy
prints the last command that prints the last command that
.I \*y .I \*y
would print and then executes it by piping it into would print and then executes it by piping it into
.IR rc (1). .IR rc (1).
.PP .PP
Both Both
@ -82,7 +84,7 @@ command again:
% \*(xx lc % \*(xx lc
% lc r* % lc r*
ramfs rc read rio rm ramfs rc read rio rm
% %
.EE .EE
.SH SEE ALSO .SH SEE ALSO
.IR 9term (1), .IR 9term (1),