cat / 012
clone

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

cat/module-path
012 / docs / nushell / README.md
README.md 4.7K rendered
1---2title: "Nushell"3sidebar_position: 14---56# Nushell78[Nushell](https://www.nushell.sh/book/) is a shell whose pipelines carry9tables: `ls`, `ps`, `open data.csv` and `http get` all hand the next10command rows and columns, with file sizes, durations and dates as values11of their own type. 012 is a spreadsheet for those tables. A table can go12through 012 in the middle of a pipeline, and nushell can run inside 01213in a notebook, its cells' outputs live parts of the sheets.1415![In nushell, ls's table goes through sheet, three of its rows are selected, and quitting sends them on for nu to keep filtering by size](../media/pipeline.gif)1617## Three ways to use them together1819| Way | Looks like | For |20|---|---|---|21| [A stage in a pipeline](pipelines.md) | `ls \| sheet \| where size > 1kb` | Looking at a table on the terminal, editing it, and sending it on to the next command |22| [A notebook](notebooks.md) | `sheet nu`, then `ls \| select name size` in a code cell named `files` | Pipelines you keep, as in Jupyter: cells run when you ask, each output under its cell, read by later cells as `$files` and, sent to a sheet, by formulas and charts |23| [A followed file](../files/following.md) | Data > Linked file, then `$app \| where status >= 500` | A log or export that keeps growing: its rows come in as they're written, and pipelines read the rows it has now |2425```mermaid26flowchart TD27 pipe["a nushell pipeline: ls | sheet"] --> stage["012 as a stage: edit the table"]28 stage -->|what you send back| next["the next command"]29 nb["a notebook: sheet nu"] -->|code cells run nu| out["outputs under their cells"]30 out -->|G| region["a live region on a sheet: nu.name"]31 file["a file that grows"] -->|Data > Linked file| linked["a linked region: nu.app"]32 linked -->|$app| nb33```3435The first needs nothing but nushell. The other two run `nu` from inside36012, so it has to be installed ([Installing37nushell](https://www.nushell.sh/book/installation.html)); without it a38cell's output says so, and the rest of 012 works as before.3940## Install the `sheet` command4142012 comes with a nushell module, `012.nu`, whose `sheet` command runs43012 in a pipeline. Write it into nushell's `scripts` folder:4445```nu46^012 nu --install-module47```4849and add the line it prints to `config.nu` (`config nu` opens it):5051```nu52use scripts/012.nu *53```5455In a new nushell, `help sheet` describes it:5657| Command | Does |58|---|---|59| `sheet` | Opens the table piped in (or a file: `sheet budget.xlsx`) and returns what you send back, with its types; `--send selection` or `--send sheet` sends it on quitting without asking ([Pipelines](pipelines.md#the-sheet-command)) |60| `sheet view` | Opens the table piped in and returns nothing |61| `sheet nu` | Opens a [notebook](notebooks.md), as `012 nu` |6263`^012 nu --install-module` refuses to replace a different file already64there unless given `--force`; given a path, it writes the module there65instead. `^012 nu --module` prints the module, to read or to put66somewhere yourself.6768Without the module, 012 is run as `^012`: in nushell, a word that69starts with a digit is a number, and the caret calls an external70command by name ([Running external71commands](https://www.nushell.sh/book/running_externals.html)). Other72shells run it as `012`.7374## A 30-second tour7576```nu77# A table in, edited, and out again, with its types78ls | select name size | sheet | where size > 1kb7980# A notebook of nushell cells, their outputs under them81sheet nu work.01282```8384In the notebook's cells, each run with Shift+Enter:8586```nu87sales = open sales.csv | update Revenue { str replace -ar '[$,]' '' | into float }88$sales | group-by Region --to-table | update items { get Revenue | math sum }89```9091The second cell reads the first's output as `$sales`; running `sales`92again marks the second `stale` until it runs too. `G` sends an output to93a sheet, where `=SUM(nu.sales)` reads it and follows each run.9495## Pages9697| Page | For |98|---|---|99| [Pipelines](pipelines.md) | `sheet`, `012 -` and `012 --pipe`: tables in on standard input and out on standard output, sending back, the exit status |100| [Notebooks](notebooks.md) | `sheet nu` and `012 nu`: code and note cells, their keys, running, `$name`, `$selection` and `$sheet.A1:C9`, outputs sent to sheets as `nu.name`, saving and trust |101| [Types](types.md) | How each nushell type becomes a cell and goes back, and what doesn't survive the trip |102| [Cookbook](cookbook.md) | Worked examples: disk usage, a log followed live, a CSV cleaned and summarized, an API, processes, git history |103104Nushell's own [book](https://www.nushell.sh/book/) explains105[pipelines](https://www.nushell.sh/book/pipelines.html),106[tables](https://www.nushell.sh/book/working_with_tables.html) and107[types](https://www.nushell.sh/book/types_of_data.html); the pages here108link to the parts they build on.