diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 12:31:48 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 12:31:48 -0300 |
| commit | beb895a93f5320e3b98d66a6c18528de9a2ec37b (patch) | |
| tree | b7cb58b5d769267dd317a577daadc0a2cba59b97 /docs/typ/scripting.typ | |
| parent | 09da0f673cfd9fdb83c4e48a2fa73a274aff4a6f (diff) | |
| download | pardes-beb895a93f5320e3b98d66a6c18528de9a2ec37b.tar.gz pardes-beb895a93f5320e3b98d66a6c18528de9a2ec37b.zip | |
Scripts find the session as m=\$PARDES_MOUNT, else 9p; SPC q quits; upper keeps a selection's newline and its tag words once; the reference takes line files, init errors, dumps, dials and Save on +Tutor
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'docs/typ/scripting.typ')
| -rw-r--r-- | docs/typ/scripting.typ | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/docs/typ/scripting.typ b/docs/typ/scripting.typ index 9b67ac76..b293bdb3 100644 --- a/docs/typ/scripting.typ +++ b/docs/typ/scripting.typ @@ -14,12 +14,13 @@ Shells and command panes in a session get `PARDES_9P` (its socket) and or text also gets `$winid`, the serial of the pane it was clicked in, as acme's commands do (unset from a column's or the workspace's tag). -- *With a mount* (`$NINE_MOUNT` set, by `9ns --mntgen`; see setup) the - session is a directory: - #cmd("s=${PARDES_9P##*/pardes-9p-}; m=$NINE_MOUNT/pardes/${s%.sock}\ncat \"$m/index\"") -- *Without one*, plan9port's `9p` talks to the socket: - `cat $m/x` is `9p -a "unix!$PARDES_9P" read x`, and `echo y > $m/x` is - `echo y | 9p -a "unix!$PARDES_9P" write x`. +Under `9ns --mntgen` (see setup) every pane also gets `PARDES_MOUNT`, the +session as a directory. That is the session line every recipe here starts +from: +#cmd("m=${PARDES_MOUNT:-}\ncat \"$m/index\"") +When it is empty (no mount), plan9port's `9p` talks to the socket instead: +`cat $m/x` is `9p -a "unix!$PARDES_9P" read x`, and `echo y > $m/x` is +`echo y | 9p -a "unix!$PARDES_9P" write x`. = Your first tag word <first-tag-word> @@ -32,8 +33,8 @@ clicked in and reloads the pane. It finds the pane through `$winid`, not #!/bin/sh # Fmt: gofmt the Go file whose tag it was clicked in, then reload it n=${winid:?Fmt: click me in a pane tag} -if [ -n "$NINE_MOUNT" ]; then - s=${PARDES_9P##*/pardes-9p-}; m=$NINE_MOUNT/pardes/${s%.sock} +m=${PARDES_MOUNT:-} +if [ -n "$m" ]; then rd() { cat "$m/$1"; }; wr() { cat > "$m/$1"; } else rd() { 9p -a "unix!$PARDES_9P" read "$1"; } @@ -53,7 +54,7 @@ log and add it to each new `.go` pane (with a mount): ```sh #!/bin/sh # fmt-tags: put Fmt in the tag of every Go file opened from now on -s=${PARDES_9P##*/pardes-9p-}; m=$NINE_MOUNT/pardes/${s%.sock} +m=${PARDES_MOUNT:?fmt-tags: needs 9ns --mntgen} exec 3<>$m/log; echo 'follow new' >&3 while read -r what serial name <&3; do case $what:$name in new:*.go) printf ' Fmt' >> $m/pane/$serial/tag ;; esac @@ -104,13 +105,13 @@ clicks are pardes's again: ```bash #!/bin/bash # upper PANE: own the tag words Upper and Done in pane PANE -s=${PARDES_9P##*/pardes-9p-}; m=$NINE_MOUNT/pardes/${s%.sock}; p=$m/pane/$1 -printf ' Upper Done' >> $p/tag +m=${PARDES_MOUNT:?upper: needs 9ns --mntgen}; p=$m/pane/$1 +grep -q ' Upper Done' $p/tag || printf ' Upper Done' >> $p/tag exec 3<>$p/event # hold event on fd 3, this shell's own while IFS= read -r rec <&3; do read -r head q1 flag n text <<< "$rec" # e.g. Mx31 36 1 5 Upper case $head$text in - [EFKM][Xx]*Upper) sel=$(cat $p/sel); printf %s "${sel^^}" > $p/sel ;; + [EFKM][Xx]*Upper) sel=$(cat $p/sel; echo x); sel=${sel%x}; printf %s "${sel^^}" > $p/sel ;; [EFKM][Xx]*Done) break ;; [EFKM][XxLl]*) printf '%s\n' "$rec" >&3 ;; # not ours: do what it would esac # I D i d report edits: nothing to do |
