cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

Notebook demos re-recorded; diagrams in the nushell pages; r runs a cell where Ctrl+Enter can't

Dami committed e1a9129
The notebook, recipe and followed-log tapes run cells with Esc then r,
as ttyd sends Shift+Enter and Ctrl+Enter as Enter. Mermaid diagrams
show a cell's run states, the order cells run in, opening a notebook
from elsewhere, what quitting sends, and the three ways to combine 012
and nushell.
commit
e1a9129696d95a16fe40673b6a98e7aa7555a32e
parent
41fea2f93a7252a37478e2e8b68056be7693c40d
author
Dami <dami.etoile@gmail.com>
kind
docs risk score 0.8 of 3, Jev's estimate
16 files changed, +164 -48
MREADME.md2+-
MROADMAP.md2+-
Mcmd/012/main.go2+-
Mdemos/follow-log.tape15++++---
Mdemos/notebook.tape62++++++++++++++++++++++-------
Mdemos/nu-recipe.tape29+++++++++-----
Mdocs/contributing/architecture.md2+-
Mdocs/media/follow-log.gifbin
Mdocs/media/notebook.gifbin
Mdocs/media/nu-recipe.gifbin
Mdocs/nushell/README.md10+++++
Mdocs/nushell/notebooks.md65+++++++++++++++++++++++++-----
Mdocs/nushell/pipelines.md17++++++++
Mdocs/reference/keys.md3+-
Minternal/ui/notebook.go1+
Mwebsite/src/pages/index.tsx2+-
M README.md +1 -1
M ROADMAP.md +1 -1
M cmd/012/main.go +1 -1
M demos/follow-log.tape +8 -7
M demos/notebook.tape +47 -15
@@ -1,7 +1,8 @@
1-# Notebooks: 012 nu opens a notebook at the nu❯ prompt. Each pipeline's2-# table becomes a named region; a second reads the first as $sales, and3-# giving sales a new command runs it again and then the region reading4-# it. Needs nu on the PATH.1+# Notebooks: 012 nu opens a notebook, its first cell ready to type in.2+# A code cell reads a CSV as sales, a second reads it as $sales, and its3+# output goes to a sheet (G) where a formula sums it; with the notebook4+# reactive, editing sales runs both again and the sheet follows. The terminal (ttyd) sends Shift+Enter as Enter, so5+# cells run with Esc then r. Needs nu on the PATH.56 Output out/notebook.gif67 Source lib/setup.tape78
@@ -11,22 +12,53 @@ Sleep 2s
1112 Show1213 1314 Sleep 800ms14-Type "sales = open data/sales.csv | where Region in [North South] | select Region Quarter Units"15+Type@25ms "sales = open data/sales.csv | where Region in [North South] | select Region Quarter Units"1516 Sleep 500ms16-Enter17+Escape18+Type "r"1719 Sleep 1.5s18-Type "$sales | where Units > 250 | sort-by Units --reverse"19-Sleep 500ms20+Type "b"2021 Enter22+Type@25ms "top = $sales | where Units > 250 | sort-by Units --reverse"23+Sleep 500ms24+Escape25+Type "r"2126 Sleep 2s22-Screenshot out/stills/notebook-regions.png23-Type "sales = open data/sales.csv | where Quarter == Q4 | select Region Quarter Units"27+Screenshot out/stills/notebook-cells.png28+Type "G"29+Sleep 800ms30+Enter31+Sleep 1.2s32+Ctrl+K33+Type@60ms "next sheet"2434 Sleep 500ms2535 Enter26-Sleep 2.5s36+Sleep 600ms37+Right Right Right Right38+Type "=SUM(nu.top)" Enter39+Sleep 1.5s40+Screenshot out/stills/notebook-sent.png41+Ctrl+K42+Type@60ms "previous sheet"43+Sleep 500ms44+Enter45+Sleep 600ms46+Ctrl+K47+Type@80ms "reactive"48+Sleep 600ms49+Enter50+Sleep 400ms51+Up Up52+Sleep 300ms53+Enter54+Type@30ms " | where Quarter != Q1"2755 Escape56+Type "r"57+Sleep 2.5s58+Screenshot out/stills/notebook-reactive.png59+Ctrl+K60+Type@60ms "next sheet"2861 Sleep 500ms29-Down Down Down30-Sleep 1.5s31-Screenshot out/stills/notebook-refreshed.png32-Sleep 1.5s62+Enter63+Sleep 2s64+Screenshot out/stills/notebook-sum.png
M demos/nu-recipe.tape +19 -10
M docs/contributing/architecture.md +1 -1
M docs/media/follow-log.gif +0 -0

Binary file.

M docs/media/notebook.gif +0 -0

Binary file.

M docs/media/nu-recipe.gif +0 -0

Binary file.

M docs/nushell/README.md +10 -0
M docs/nushell/notebooks.md +55 -10
@@ -16,7 +16,7 @@ files = ls | where type == file
1616 $files | where size > 1kb | sort-by size --reverse1717 ```1818 19-![A notebook: a note, a cell listing files, a second reading it as $files, its output sent to a sheet and summed there](../media/notebook.gif)19+![A notebook: a cell reads a CSV as sales, a second reads it as $sales, its output is sent to a sheet and summed there, and with the notebook reactive, editing sales runs both again and the sum follows](../media/notebook.gif)2020 2121 Open one from a shell with `012 nu`, or from nushell with `sheet nu`2222 (`sheet` comes from 012's nushell module: [Install the `sheet`
@@ -49,10 +49,29 @@ A cell is its head, its source and, for a code cell, its output:
4949 5050 The head says how many runs came before this one (`[2]`, `[*]` while it5151 runs, `[ ]` before it has), the cell's name, and at the right how its run52-stands: `running`, `waiting` for the cell before it, `✓` or `failed` with53-how long it took, `stale`, `not run`, or `saved` for an output read from54-the file. A source is shown whole: a line too long for the screen wraps55-before a pipe where it can, its next rows indented.52+stands, `saved` for an output read from the file:53+54+```mermaid55+stateDiagram-v256+ notrun: not run57+ waiting: waiting58+ running: running59+ done: ✓ and how long it took60+ failed: failed, and nu's message under it61+ stale: stale62+ [*] --> notrun63+ notrun --> waiting: Shift+Enter, Ctrl+Enter, F964+ waiting --> running: the cell before it ends65+ running --> done66+ running --> failed: an error, or ii67+ done --> stale: a cell it reads runs again, or its source changes68+ stale --> waiting: run again69+ failed --> waiting: run again70+ done --> waiting: run again71+```72+73+A source is shown whole: a line too long for the screen wraps before a74+pipe where it can, its next rows indented.5675 5776 Outputs are drawn by what they are, with values formatted as cells5877 ([Types](types.md)):
@@ -83,7 +102,6 @@ type into the selected cell.
83102 84103 ```mermaid85104 stateDiagram-v286- direction LR87105 [*] --> Command88106 Command --> Edit: Enter, !89107 Edit --> Command: Esc
@@ -98,7 +116,7 @@ stateDiagram-v2
98116 | Home, End, PgUp, PgDn | The first cell, the last, a screen up or down |99117 | Enter | Edit the cell; on an output, open it full-screen |100118 | Shift+Enter | Run the cell and select the next, adding one at the end |101-| Ctrl+Enter | Run the cell, staying on it |119+| Ctrl+Enter, `r` | Run the cell, staying on it |102120 | Alt+Enter | Run the cell and add a code cell under it |103121 | F9 | Run every cell |104122 | `a`, `b` | Add a code cell above, below |
@@ -122,6 +140,11 @@ stateDiagram-v2
122140 | Ctrl+A, Ctrl+E | The start, the end of the line |123141 | Tab | Complete the word at the caret: a cell's `$name`, `$selection`, a linked file, or one of nu's commands |124142 143+A terminal without the kitty keyboard protocol sends Shift+Enter and144+Ctrl+Enter as Enter ([Keys the terminal has to tell145+apart](../reference/keys.md#keys-the-terminal-has-to-tell-apart)): there146+Esc then `r` runs the cell, and Alt+Enter runs it and adds one under it.147+125148 Every action is a command, in **Data > Notebook**, the palette and the126149 shortcuts (Ctrl+/), and File, Edit and the sheet tabs work as anywhere;127150 commands for a sheet's cells are off on a notebook's tab. Changes to
@@ -159,6 +182,18 @@ A name is letters, digits and `_`, not starting with a digit or `__`;
159182 can't share a name: the second says so and doesn't run until it's160183 renamed.161184 185+What a cell reads decides the order cells run in: each after the cells186+it reads, and a cell that hasn't run first when one reading it runs. A187+cell reading itself, directly or through others, doesn't run.188+189+```mermaid190+flowchart TD191+ files["files = ls"] -->|$files| big["big = $files | where size > 1kb"]192+ app["a linked file, app.csv"] -->|$app| errors["errors = $app | where status >= 500"]193+ big -->|G sends it to a sheet| region["the region big, on a sheet"]194+ region --> sum["=SUM(nu.big)"]195+```196+162197 A cell reads the sheets two ways, each a table:163198 164199 | In a cell | Is |
@@ -178,7 +213,7 @@ directly or through others, `stale`: they were made from what it printed
178213 before. So is a cell's own output once its source is changed.179214 180215 ```mermaid181-flowchart LR216+flowchart TD182217 run["files runs again"] --> stale["big, and cells reading big: stale"]183218 stale -->|reactive off| you["run them when you want"]184219 stale -->|reactive on| again["they run again, each after what it reads"]
@@ -230,8 +265,18 @@ Opening a file never runs its cells. Like
230265 run as you, with your files, so a notebook saved on another computer231266 asks once before its cells run:232267 233-```234-Run this file's notebook cells? Enter Run Esc Cancel268+```mermaid269+sequenceDiagram270+ participant You271+ participant N as The notebook272+ participant Nu as nu273+ You->>N: open a file saved on another computer274+ N-->>You: its cells and saved outputs, nothing run275+ You->>N: Shift+Enter, or F9276+ N-->>You: Run this file's notebook cells?277+ You->>N: Enter278+ N->>Nu: the cells, one at a time279+ Nu-->>N: their outputs235280 ```236281 237282 Cells you write in a notebook made here run without asking. The options,
M docs/nushell/pipelines.md +17 -0
M docs/reference/keys.md +2 -1
M internal/ui/notebook.go +1 -0
M website/src/pages/index.tsx +1 -1