First pass at updating all documentation formatting and cleaning up output of examples (#2031)

This commit is contained in:
Joseph T. Lyons
2020-06-23 14:21:47 -04:00
committed by GitHub
parent d095cb91e4
commit 053bd926ec
81 changed files with 1069 additions and 679 deletions

View File

@ -2,7 +2,7 @@
Pick any command from the checklist and write a comment acknowledging you started work.
# Instructions for documenting a Nu command of your choosing
## Instructions for documenting a Nu command of your choosing
Name the file after the command, like so:
@ -10,7 +10,7 @@ Name the file after the command, like so:
Example: If you want to add documentation for the Nu command `enter`, create a file named `enter.md`, write documentation, save it at `/docs/commands/[your_command_picked].md` as and create your pull request.
# What kind of documentation should I write?
## What kind of documentation should I write?
Anything you want that you believe it *best* documents the command and the way you would like to see it. Here are some of our ideas of documentation we would *love* to see (feel free to add yours):
@ -18,7 +18,7 @@ Anything you want that you believe it *best* documents the command and the way y
* Description of the command.
* Command usage.
# Anything else?
## Anything else?
Of course! (These are drafts) so feel free to leave feedback and suggestions in the same file.

View File

@ -1,9 +1,11 @@
# alias
This command allows you to define shortcuts for other common commands. By default, they only apply to the current session. To persist them, add `--save`.
Syntax: `alias {flags} <name> [<parameters>] {<body>}`
The command expects three parameters:
* the name of alias
* the parameters as a space-separated list (`[a b ...]`), can be empty (`[]`)
* the body of the alias as a `{...}` block
@ -15,6 +17,7 @@ The command expects three parameters:
## Examples
Define a custom `myecho` command as an alias:
```shell
> alias myecho [msg] { echo $msg }
> myecho "hello world"
@ -22,6 +25,7 @@ hello world
```
Since the parameters are well defined, calling the command with the wrong number of parameters will fail properly:
```shell
> myecho hello world
error: myecho unexpected world
@ -31,6 +35,7 @@ error: myecho unexpected world
```
The suggested help command works!
```shell
> myecho -h
@ -47,22 +52,29 @@ flags:
## Persistent aliases
Aliases are most useful when they are persistent. For that, add them to your startup config:
```
```shell
> config --set [startup ["alias myecho [msg] { echo $msg }"]]
```
This is fine for the first alias, but since it overwrites the startup config, you need a different approach for additional aliases.
To add a 2nd alias:
```shell
> config --get startup | append "alias s [] { git status -sb }" | config --set_into startup
```
config --get startup | append "alias s [] { git status -sb }" | config --set_into startup
```
This first reads the `startup` config (a table of strings), then appends another alias, then sets the `startup` config with the output of the pipeline.
To make this process easier, you could define another alias:
```
```shell
> alias addalias [alias-string] { config --get startup | append $alias-string | config --set_into startup }
```
Then use that to add more aliases:
```
addalias "alias s [] { git status -sb }"
```shell
> addalias "alias s [] { git status -sb }"
```

View File

@ -1,7 +1,9 @@
# append
This command allows you to append the given row to the table.
**Note**:
- `append` does not change a file itself. If you want to save your changes, you need to run the `save` command
- if you want to add something containing a whitespace character, you need to put it in quotation marks
@ -11,37 +13,37 @@ Let's add more cities to this table:
```shell
> open cities.txt | lines
━━━┯━━━━━━━━━━━━
# │ <value>
───┬────────────
# │
───┼────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
━━━┷━━━━━━━━━━━━
───┴────────────
```
You can add a new row by using `append`:
```shell
> open cities.txt | lines | append Beijing
━━━┯━━━━━━━━━━━━
# │ <value>
───┬────────────
# │
───┼────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
4 │ Beijing
━━━┷━━━━━━━━━━━━
───┴────────────
```
It's not possible to add multiple rows at once, so you'll need to call `append` multiple times:
```shell
> open cities.txt | lines | append Beijing | append "Buenos Aires"
━━━┯━━━━━━━━━━━━━━
# │ <value>
───┬──────────────
# │
───┼──────────────
0 │ Canberra
1 │ London
@ -49,5 +51,5 @@ It's not possible to add multiple rows at once, so you'll need to call `append`
3 │ Washington
4 │ Beijing
5 │ Buenos Aires
━━━┷━━━━━━━━━━━━━━
───┴──────────────
```

View File

@ -4,11 +4,13 @@ calc is a command that takes a math expression from the pipeline and calculates
This command supports the following operations -
operations :
operations:
* binary operators: +, -, *, /, % (remainder), ^ (power)
* unary operators: +, -, ! (factorial)
functions :
functions:
* sqrt, abs
* exp, ln, log10
* sin, cos, tan, asin, acos, atan, atan2
@ -18,40 +20,74 @@ functions :
* max(x, ...), min(x, ...): maximum and minimum of 1 or more numbers
constants:
* pi
* e
## Examples -
## Examples
```
```shell
> echo "1+2+3" | calc
6.000000000000000
6.0
```
```shell
> echo "1-2+3" | calc
2.000000000000000
2.0
```
```shell
> echo "-(-23)" | calc
23.00000000000000
23.0
```
```shell
> echo "5^2" | calc
25.00000000000000
25.0
```
```shell
> echo "5^3" | calc
125.0000000000000
125.0
```
```shell
> echo "min(5,4,3,2,1,0,-100,45)" | calc
-100.0000000000000
-100.0
```
```shell
> echo "max(5,4,3,2,1,0,-100,45)" | calc
45.00000000000000
> echo "sqrt(2) | calc"
45.0
```
```shell
> echo sqrt(2) | calc
1.414213562373095
```
```shell
> echo pi | calc
3.141592653589793
> echo e | calc
2.718281828459045
> echo "sin(pi / 2)" | calc
1.000000000000000
> echo "floor(5999/1000)" | calc
5.000000000000000
```
```shell
> echo e | calc
2.718281828459045
```
open abc.json
```shell
> echo "sin(pi / 2)" | calc
1.0
```
```shell
> echo "floor(5999/1000)" | calc
5.0
```
```shell
> open abc.json
───┬──────
# │ size
───┼──────
@ -64,10 +100,12 @@ constants:
6999
71639
───┴──────
```
open abc.json | format "({size} + 500) * 4"
```shell
> open abc.json | format "({size} + 500) * 4"
───┬──────────────────
# │ <value>
# │
───┼──────────────────
0(816 + 500) * 4
1(1627 + 500) * 4
@ -78,10 +116,12 @@ constants:
6(999 + 500) * 4
7(1639 + 500) * 4
───┴──────────────────
```
open abc.json | format "({size} + 500) * 4" | calc
```shell
> open abc.json | format "({size} + 500) * 4" | calc
───┬───────────
# │ <value>
# │
───┼───────────
0 │ 5264.0000
1 │ 8508.0000
@ -92,10 +132,12 @@ constants:
6 │ 5996.0000
7 │ 8556.0000
───┴───────────
```
open abc.json | format "({size} - 1000) * 4" | calc
```shell
> open abc.json | format "({size} - 1000) * 4" | calc
───┬────────────
# │ <value>
# │
───┼────────────
0 │ -736.0000
1 │ 2508.0000
@ -110,7 +152,7 @@ constants:
Note that since `calc` uses floating-point numbers, the result may not always be precise.
```
```shell
> echo "floor(5999999999999999999/1000000000000000000)" | calc
6.000000000000000
6.0
```

View File

@ -3,6 +3,7 @@
This command allows us to filters out rows with empty columns. Other commands are capable of feeding `compact` with their output through pipelines.
## Usage
```shell
> [input-command] | compact [column-name]
```

View File

@ -4,7 +4,7 @@ Configuration management.
Syntax: `config {flags}`
### Flags
## Flags
--load <file path shape>
load the config from the path give
@ -27,7 +27,7 @@ Syntax: `config {flags}`
--path
return the path to the config file
### Variables
## Variables
| Variable | Type | Description |
| ------------------ | ---------------------- | ------------------------------------------------------------------------- |

View File

@ -2,47 +2,57 @@
This command counts the number of rows in a table.
## Examples -
## Examples
```shell
> ls
━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ created │ accessed │ modified
────┼──────────────────────────────┼───────────┼──────────┼─────────┼──────────────┼──────────────┼──────────────
0Desktop │ Directory │ │ 4.1 KB │ 2 months ago │ 2 months ago │ 2 months ago
1 │ aur │ Directory │ │ 4.1 KB │ 4 hours ago │ 4 hours ago │ 4 hours ago
...
75.emulator_console_auth_token │ File │ │ 16 B 2 months ago │ 2 months ago │ 2 months ago
76 │ bin │ Directory │ 4.1 KB │ 2 months ago │ 2 months ago │ 2 months ago
━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
> ls | count
━━━━━━━━━
<value>
─────────
77
━━━━━━━━━
> ls | get name | count
━━━━━━━━━
<value>
─────────
77
━━━━━━━━━
> ls | where type == File | count
━━━━━━━━━
<value>
─────────
29
━━━━━━━━━
> ls | where type == Directory | count
━━━━━━━━━
<value>
─────────
48
━━━━━━━━━
> ls | where size > 2KB | count
━━━━━━━━━
<value>
─────────
57
━━━━━━━━━
────┬────────────────────┬──────┬──────────┬──────────────
# │ name │ type │ size │ modified
────┼────────────────────┼──────┼──────────┼──────────────
0 CODE_OF_CONDUCT.md │ File │ 3.4 KB │ 42 mins ago
1 │ CONTRIBUTING.md │ File │ 1.3 KB │ 42 mins ago
2 │ Cargo.lock │ File │ 113.3 KB │ 42 mins ago
3 Cargo.toml │ File │ 4.6 KB42 mins ago
4 │ LICENSE │ File1.1 KB │ 3 months ago
5 │ Makefile.toml │ File │ 449 B │ 5 months ago
6 │ README.md │ File │ 15.9 KB │ 31 mins ago
7 │ TODO.md │ File │ 0 B │ 42 mins ago
8 │ assets │ Dir │ 128 B │ 5 months ago
9 │ build.rs │ File │ 78 B │ 4 months ago
10 │ crates │ Dir │ 704 B │ 42 mins ago
11 │ debian │ Dir │ 352 B │ 5 months ago
12 │ docker │ Dir │ 288 B │ 3 months ago
13 │ docs │ Dir │ 192 B │ 42 mins ago
14 │ features.toml │ File │ 632 B │ 4 months ago
15 │ images │ Dir │ 160 B │ 5 months ago
16 │ rustfmt.toml │ File │ 16 B │ 5 months ago
17 │ src │ Dir │ 128 B │ 1 day ago
18 │ target │ Dir │ 160 B │ 5 days ago
19 │ tests │ Dir │ 192 B │ 3 months ago
────┴────────────────────┴──────┴──────────┴──────────────
```
```shell
> ls | count
20
```
```shell
> ls | get name | count
20
```
```shell
> ls | where type == File | count
11
```
```shell
> ls | where type == Dir | count
9
```
```shell
> ls | where size > 2KB | count
4
```

View File

@ -14,21 +14,39 @@ Use `date` to get the current date and time. Defaults to local timezone but you
```shell
> date
━━━━━━┯━━━━━━━┯━━━━━┯━━━━━━┯━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━
year │ month │ day │ hour │ minute │ second │ timezone
──────┼───────┼─────┼──────┼────────┼────────┼──────────
2019930215230 │ -03:00
━━━━━━┷━━━━━━━┷━━━━━┷━━━━━━┷━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━
> date --utc
━━━━━━┯━━━━━━━┯━━━━━┯━━━━━━┯━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━
year │ month │ day │ hour │ minute │ secondtimezone
──────┼───────┼─────┼──────┼────────┼────────┼──────────
201910105232 │ UTC
━━━━━━┷━━━━━━━┷━━━━━┷━━━━━━┷━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━
> date --local
━━━━━━┯━━━━━━━┯━━━━━┯━━━━━━┯━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━
year │ month │ day │ hour │ minute │ second │ timezone
──────┼───────┼─────┼──────┼────────┼────────┼──────────
2019930215234 │ -03:00
━━━━━━┷━━━━━━━┷━━━━━┷━━━━━━┷━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━
──────────┬────────
year 2020
month │ 6
day │ 21
hour │ 18
minute │ 3
second │ 43
timezone-04:00
──────────┴────────
```
```shell
> date --utc
──────────┬──────
year │ 2020
month │ 6
day │ 21
hour │ 22
minute │ 3
second │ 53
timezone │ UTC
──────────┴──────
```
```shell
> date --local
──────────┬────────
year │ 2020
month │ 6
day │ 21
hour │ 18
minute │ 4
second │ 3
timezone │ -04:00
──────────┴────────
```

View File

@ -4,10 +4,10 @@
## Examples
```
ls | first 2 | debug
```shell
> ls | first 2 | debug
───┬──────────────────────────────────────────
# │ <value>
# │
───┼──────────────────────────────────────────
0(name=".azure"
type="Dir"
@ -20,10 +20,13 @@
modified=2020-01-06T05:45:30.933303081Z((B
│ mdate))
───┴──────────────────────────────────────────
ls | last 8 | get type | debug
───┬─────────
# │ <value>
───┼─────────
```
```shell
> ls | last 8 | get type | debug
───┬───────────────────────
# │
───┼───────────────────────
0"Dir"
1"Dir"
2"File"
@ -32,10 +35,16 @@
5"Dir"
6"Dir"
7"Dir"
───┴─────────
open --raw Cargo.toml | size | debug
(lines=271 words=955 chars=7855 max length=7856)
du src/ | debug
───┴───────────────────────
```
```shell
> open --raw Cargo.toml | size | debug
(lines=139 words=560 chars=4607 max length=4607)
```
```shell
> du src/ | debug
(path="src"(path)
apparent=705300(bytesize)
physical=1118208(bytesize)

View File

@ -3,6 +3,7 @@
This command sets a default row's column if missing. Other commands are capable of feeding `default` with their output through pipelines.
## Usage
```shell
> [input-command] | default [column-name] [column-value]
```

View File

@ -6,21 +6,31 @@
```shell
> du src/commands
───┬──────────────┬──────────┬──────────────────────────
# │ path apparent │ physical │ directories
───┼──────────────┼──────────┼──────────┼────────────────
0 │ src/commands │ 411.5 KB │ 647.2 KB │ [table 1 rows]
───┴──────────────┴──────────┴──────────┴────────────────
─────────────┬────────────────────────────
path │ crates/nu-cli/src/commands
apparent │ 655.9 KB
physical │ 950.3 KB
directories │ [table 5 rows]
files │
─────────────┴────────────────────────────
```
```shell
> du -a src/commands
───┬──────────────┬──────────┬──────────┬─────────────────┬────────────────
# │ path apparent │ physical │ files │ directories
───┼──────────────┼──────────┼──────────┼─────────────────┼────────────────
0 │ src/commands │ 411.5 KB │ 647.2 KB │ [table 95 rows][table 1 rows]
───┴──────────────┴──────────┴──────────┴─────────────────┴────────────────
─────────────┬────────────────────────────
path │ crates/nu-cli/src/commands
apparent │ 655.9 KB
physical │ 950.3 KB
directories │ [table 5 rows]
files │ [table 118 rows]
─────────────┴────────────────────────────
```
```shell
> du *.rs
───┬──────────┬──────────┬──────────
# │ path │ apparent │ physical
───┼──────────┼──────────┼──────────
0 │ build.rs │ 78 B │ 4.1 KB
───┴──────────┴──────────┴──────────
```
```

View File

@ -6,7 +6,15 @@ Use `echo` to repeat arguments back to the user
```shell
> echo Hello world
Hello world
───┬───────
# │
───┼───────
0 │ Hello
1 │ world
───┴───────
```
```shell
> echo "Hello, world!"
Hello, world!
```
```

View File

@ -7,10 +7,10 @@ This command creates a new shell and begin at this path.
```shell
/home/foobar> cat user.json
{
"Name": "Peter",
"Age": 30,
"Telephone": 88204828,
"Country": "Singapore"
"Name": "Peter",
"Age": 30,
"Telephone": 88204828,
"Country": "Singapore"
}
/home/foobar> enter user.json
/> ls
@ -40,7 +40,7 @@ It also provides the ability to work with multiple directories at the same time.
## Note
If you `enter` a JSON file with multiple a top-level list, this will open one new shell for each list element.
If you `enter` a JSON file with multiple a top-level list, this will open one new shell for each list element.
```shell
/private/tmp> printf "1\\n2\\n3\\n" | lines | save foo.json
@ -56,4 +56,3 @@ If you `enter` a JSON file with multiple a top-level list, this will open one ne
───┴────────┴─────────────────────────┴──────────────
/>
```

View File

@ -8,7 +8,6 @@ Syntax: `> [input-command] | every <stride> {flags}`
* `--skip`, `-s`: Skip the rows that would be returned, instead of selecting them
## Examples
```shell

View File

@ -8,7 +8,7 @@ Exits the nu shell. If you have multiple nu shells, use `exit --now` to exit all
> exit
```
```
```shell
> shells
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path

View File

@ -29,4 +29,4 @@ This command loads from a URL into a cell, convert it to table if possible (avoi
────────────────
[table: 1 row]
━━━━━━━━━━━━━━━━
```
```

View File

@ -6,23 +6,26 @@ Use `first` to retrieve the first "n" rows of a table. `first` has a required am
```shell
> ps | first 1
━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
pid │ name │ status │ cpu
───────┼──────────────┼─────────┼───────────────────
60358 │ nu_plugin_ps │ Running │ 5.399802999999999
━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
─────────┬──────────────────
pid 14733
name │ nu_plugin_core_p
status │ Running
cpu │ 4.1229
mem │ 2.1 MB
virtual │ 4.8 GB
─────────┴──────────────────
```
```shell
> ps | first 5
━━━┯━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
# │ pid │ name │ status │ cpu
───┼───────┼──────────────┼─────────┼───────────────────
060754 │ nu_plugin_ps │ Running │ 4.024156000000000
160107 │ quicklookd │ Running │ 0.000000000000000
259356 │ nu │ Running │ 0.000000000000000
359216 │ zsh │ Running │ 0.000000000000000
459162 │ vim │ Running │ 0.000000000000000
━━━┷━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
───┬───────┬──────────────────┬─────────┬──────────┬─────────┬─────────
# │ pid │ name │ status │ cpu │ mem │ virtual
───┼───────┼──────────────────┼─────────┼──────────┼─────────┼─────────
014747 │ nu_plugin_core_p │ Running │ 3.5653 │ 2.1 MB │ 4.8 GB
114735 │ Python │ Running │ 100.0008 │ 27.4 MB │ 5.4 GB
214734 │ mdworker_shared │ Running │ 0.0000 │ 18.4 MB │ 4.7 GB
314729 │ mdworker_shared │ Running │ 0.0000 │ 8.2 MB │ 5.0 GB
414728 │ mdworker_shared │ Running │ 0.0000 │ 8.0 MB │ 4.9 GB
───┴───────┴──────────────────┴─────────┴──────────┴─────────┴─────────
```

View File

@ -4,7 +4,7 @@ Format columns into a string using a simple pattern
Syntax: `format <pattern>`
### Parameters
## Parameters
* `<pattern>`: the pattern to match
@ -28,10 +28,10 @@ Let's say we have a table like this:
```shell
> open pets.csv | format "{name} is a {age} year old {animal}"
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ <value>
# │
───┼─────────────────────────────────
0 │ Tom is a 7 year old cat
1 │ Alfred is a 10 year old dog
2 │ Linda is a 1 year old chameleon
━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
```

View File

@ -4,7 +4,7 @@ Converts csv data into table. Use this when nushell cannot determine the input f
## Example
Let's say we have the following file :
Let's say we have the following file:
```shell
> cat pets.txt
@ -14,7 +14,7 @@ dog, Alfred, 10
chameleon, Linda, 1
```
`pets.txt` is actually a .csv file but it has the .txt extension, `open` is not able to convert it into a table :
`pets.txt` is actually a .csv file but it has the .txt extension, `open` is not able to convert it into a table:
```shell
> open pets.txt
@ -24,7 +24,7 @@ dog, Alfred, 10
chameleon, Linda, 1
```
To get a table from `pets.txt` we need to use the `from csv` command :
To get a table from `pets.txt` we need to use the `from csv` command:
```shell
> open pets.txt | from csv
@ -37,7 +37,7 @@ To get a table from `pets.txt` we need to use the `from csv` command :
━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━
```
To ignore the csv headers use `--headerless` :
To ignore the csv headers use `--headerless`:
```shell
━━━┯━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━
@ -48,7 +48,7 @@ To ignore the csv headers use `--headerless` :
━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━
```
To split on a character other than ',' use `--separator` :
To split on a character other than ',' use `--separator`:
```shell
> open pets.txt
@ -105,7 +105,7 @@ Note that separators are currently provided as strings and need to be wrapped in
| ^
```
It is also considered an error to use a separator greater than one char :
It is also considered an error to use a separator greater than one char:
```shell
> open pets.txt | from csv --separator '123'

View File

@ -4,7 +4,8 @@ Converts ini data into table. Use this when nushell cannot determine the input f
## Example
Let's say we have the following `.txt` file :
Let's say we have the following `.txt` file:
```shell
> open sample.txt
[SectionOne]
@ -14,7 +15,7 @@ integer = 1234
string1 = 'Case 1'
```
This file is actually a ini file, but the file extension isn't `.ini`. That's okay, we can use the `from ini` command :
This file is actually a ini file, but the file extension isn't `.ini`. That's okay, we can use the `from ini` command:
```shell
> open sample.txt | from ini | get SectionOne

View File

@ -1,15 +1,14 @@
# from json
Parse text as `.json` and create table. Use this when nushell cannot dertermine the input file extension.
Parse text as `.json` and create table. Use this when nushell cannot determine the input file extension.
Syntax: `from json {flags}`
### Flags:
## Flags
--objects
treat each line as a separate value
## Examples
```shell

View File

@ -11,6 +11,9 @@ Parses OpenDocument Spreadsheet binary data into a table. `open` calls `from ods
─────────────────
[table 26 rows]
─────────────────
```
```shell
> open abc.ods --raw
Length: 4816 (0x12d0) bytes
0000: 50 4b 03 04 14 00 00 00 00 00 00 00 00 00 85 6c PK.............l
@ -20,6 +23,9 @@ Length: 4816 (0x12d0) bytes
12a0: 00 61 10 00 00 4d 45 54 41 2d 49 4e 46 2f 6d 61 .a...META-INF/ma
12b0: 6e 69 66 65 73 74 2e 78 6d 6c 50 4b 05 06 00 00 nifest.xmlPK....
12c0: 00 00 06 00 06 00 5a 01 00 00 60 11 00 00 00 00 ......Z...`.....
```
```shell
> open abc.ods --raw | from ods
─────────────────
Sheet1

View File

@ -1,8 +1,11 @@
# from toml
Converts toml data into table. Use this when nushell cannot determine the input file extension.
## Example
Let's say we have the following Rust .lock file :
Let's say we have the following Rust .lock file:
```shell
> open Cargo.lock
# This file is automatically @generated by Cargo.
@ -10,14 +13,11 @@ Let's say we have the following Rust .lock file :
...
```
The "Cargo.lock" file is actually a .toml file, but the file extension isn't .toml. That's okay, we can use the `from toml` command :
The "Cargo.lock" file is actually a .toml file, but the file extension isn't .toml. That's okay, we can use the `from toml` command:
```shell
> open Cargo.lock | from toml
━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
metadata │ package
────────────────┼───────────────────
[table: 1 row][table: 154 rows]
━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
─────────┬──────────────────
package │ [table 459 rows]
───────────────────────────
```

View File

@ -4,7 +4,7 @@ Parse text as `.tsv` and create table.
Syntax: `from tsv {flags}`
### Flags:
## Flags
--headerless
don't treat the first row as column names

View File

@ -6,9 +6,10 @@ Parse [url-encoded string](https://url.spec.whatwg.org/#application/x-www-form-u
```shell
> echo 'bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter' | from url
━━━━━━━━━━┯━━━━━━━━┯━━━━━━┯━━━━━━━━
bread │ cheese │ meat │ fat
──────────┼────────┼──────┼────────
baguette │ comté │ ham │ butter
━━━━━━━━━━┷━━━━━━━━┷━━━━━━┷━━━━━━━━
────────┬──────────
bread │ baguette
cheese │ comté
meat │ ham
fat │ butter
────────┴──────────
```

View File

@ -31,7 +31,7 @@ Pass the output of the `open` command to `from vcf` to get a correctly formatted
```shell
> open contacts.txt | from vcf | get properties | where $it.name == "FN" | select value
─────┬──────────────────────
# │ value
# │
─────┼──────────────────────
0 │ John Doe
```

View File

@ -4,7 +4,7 @@ Parses MS Excel binary data into a table. `open` calls `from xlsx` automatically
## Examples
```sh
```shell
> open abc.xlsx
─────────────────
Sheet1

View File

@ -20,5 +20,4 @@ flags: false
───────────┼─────────┼───────
from-yaml │ command │ No
━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━
```

View File

@ -27,7 +27,7 @@ Use this when nushell cannot determine the input file extension.
## Example for `from csv`
Let's say we have the following file :
Let's say we have the following file:
```shell
> cat pets.txt
@ -37,7 +37,7 @@ dog, Alfred, 10
chameleon, Linda, 1
```
`pets.txt` is actually a .csv file but it has the .txt extension, `open` is not able to convert it into a table :
`pets.txt` is actually a .csv file but it has the .txt extension, `open` is not able to convert it into a table:
```shell
> open pets.txt

View File

@ -4,7 +4,7 @@ Open given cells as text.
Syntax: `get ...args`
### Parameters:
## Parameters
* `args`: optionally return additional data by path
@ -14,41 +14,50 @@ If we run `sys` we receive a table which contains tables itself:
```shell
> sys
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━
host │ cpu │ disks │ mem │ temp │ net │ battery
────────────────────────────────────────┼────────────────────────────────────┼────────────────┼───────────────────────────────────────┼────────────────┼────────────────┼────────────────
[row arch hostname name release uptime │ [row cores current ghz max ghz min │ [table 7 rows][row free swap free swap total total][table 6 rows][table 3 rows][table 1 rows]
users] │ ghz] │ │ │ │ │
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━
─────────┬─────────────────────────────────────────
host [row 7 columns]
cpu │ [row cores current ghz max ghz min ghz]
disks │ [table 4 rows]
mem │ [row free swap free swap total total]
net │ [table 19 rows]
battery │ [table 1 rows]
─────────┴─────────────────────────────────────────
```
To access one of the embedded tables we can use the `get` command
```shell
> sys | get cpu
━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
cores │ current ghz │ min ghz │ max ghz
───────┼───────────────────┼────────────────────┼───────────────────
4 │ 1.530000000000000 │ 0.5000000000000000 │ 3.500000000000000
━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
─────────────┬────────
cores 16
current ghz │ 2.4000
min ghz │ 2.4000
max ghz │ 2.4000
─────────────┴────────
```
```shell
> sys | get battery
━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━
vendor │ model │ mins to full
────────┼──────────┼──────────────────
SMP │ L14M2P21 │ 16.7024000000000
━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━
───────────────┬──────────
vendor │ DSY
model │ bq40z651
cycles │ 43
mins to empty │ 70.0000
───────────────┴──────────
```
There's also the ability to pass multiple parameters to `get` which results in an output like this
```shell
sys | get cpu battery
━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
# │ cores │ current ghz │ min ghz │ max ghz │ vendor │ model │ mins to full
───┼───────┼───────────────────┼────────────────────┼───────────────────┼────────┼──────────┼───────────────────
0 41.500000000000000 │ 0.50000000000000003.500000000000000 │ │ │
1 │ │ │ │ │ SMP │ L14M2P21 │ 16.94503000000000
━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
```
───┬───────┬─────────────┬─────────┬─────────
# │ cores │ current ghz │ min ghz │ max ghz
───┼───────┼──────────────────────┼─────────
016 2.4000 │ 2.4000 │ 2.4000
───┴───────┴─────────────┴─────────┴─────────
───┬────────┬──────────┬────────┬───────────────
# │ vendor │ model │ cycles │ mins to empty
───┼────────┼──────────┼────────┼───────────────
1 │ DSY │ bq40z651 │ 43 │ 70.0000
───┴────────┴──────────┴────────┴───────────────
```

View File

@ -7,14 +7,16 @@ As demonstrated in the following example, it's particularly handy when working w
## Examples
```shell
open sample_data.ods | get SalesOrders
> open sample_data.ods | get SalesOrders
────┬────────────┬─────────┬──────────┬─────────┬─────────┬───────────┬───────────
# │ Column0 │ Column1 │ Column2 │ Column3 │ Column4 │ Column5 │ Column6
────┼────────────┼─────────┼──────────┼─────────┼─────────┼───────────┼───────────
0 │ OrderDate │ Region │ Rep │ Item │ Units │ Unit Cost │ Total
1 │ 2018-01-06 │ East │ Jones │ Pencil │ 95.0000 │ 1.9900 │ 189.0500
```
open sample_data.ods | get SalesOrders | headers
```shell
> open sample_data.ods | get SalesOrders | headers
────┬────────────┬─────────┬──────────┬─────────┬─────────┬───────────┬───────────
# │ OrderDate │ Region │ Rep │ Item │ Units │ Unit Cost │ Total
────┼────────────┼─────────┼──────────┼─────────┼─────────┼───────────┼───────────

View File

@ -14,26 +14,40 @@ Here are some tips to help you get started.
* help commands - list all available commands
* help <command name> - display help about a particular command
Nushell works on the idea of a "pipeline". Pipelines are commands connected with the '|' character.
Each stage in the pipeline works together to load, parse, and display information to you.
[Examples]
List the files in the current directory, sorted by size:
ls | sort-by size
Get information about the current system:
sys | get host
Get the processes on your system actively using CPU:
ps | where cpu > 0
You can also learn more at https://www.nushell.sh/book/
```
```shell
> help commands
━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
────┬──────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
# │ name │ description
────┼──────────────┼────────────────────────────────────────────────────────────────────────────────────────
0add Add a new field to the table.
1 │ autoview │ View the contents of the pipeline as a table or list.
2cd │ Change to a new path.
3config │ Configuration management.
4 │ cp Copy files.
5dateGet the current datetime.
────┼──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
0 aliasDefine a shortcut for another command.
1 │ append │ Append the given row to the table
2 autoview │ View the contents of the pipeline as a table or list.
3 build-string │ Builds a string from the arguments
4 │ calDisplay a calendar.
5 calcParse a math expression into a number
...
70trim Trim leading and following whitespace from text data.
71versionDisplay Nu version
72 │ where │ Filter table to match the condition.
73 │ whichFinds a program file.
━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
83whereFilter table to match the condition.
84which Finds a program file.
85 │ with-env │ Runs a block with an environment set. Eg) with-env [NAME 'foo'] { echo $nu.env.NAME }
86 │ wrap Wraps the given data in a table.
────┴──────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```
```shell
@ -41,7 +55,24 @@ You can also learn more at https://www.nushell.sh/book/
Change to a new path.
Usage:
> cd (directory)
> cd (directory) {flags}
Parameters:
(directory) the directory to change to
Flags:
-h, --help: Display this help message
Examples:
Change to a new directory called 'dirname'
> cd dirname
Change to your home directory
> cd
Change to your home directory (alternate version)
> cd ~
Change to the previous directory
> cd -
```

View File

@ -4,7 +4,7 @@ Creates a new table with a histogram based on the column name passed in.
Syntax: `histogram <column_name> ...args`
### Parameters
## Parameters
* `<column-name>`: name of the column to graph by
* `args`: column name to give the histogram's frequency column
@ -23,7 +23,7 @@ Let's say we have this file `random_numers.csv` which contains 50 random numbers
01
12
22
...
...
475
485
491

View File

@ -6,12 +6,12 @@ Displays the last 100 commands.
```shell
> history
━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ <value>
────┼───────────────────────────────────────────────────────────────────────────
...
97ls
98 │ ls | where accessed < 1d
99cd
━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
─────┬────────────────────────────────────────────────────────────────────────
# │
─────────────────────────────────────────────────────────────────────────────
...
97 date
98 │ ls
99 ls -fa
─────┴────────────────────────────────────────────────────────────────────────
```

View File

@ -6,26 +6,34 @@ This command increments the value of variable by one.
```shell
> open rustfmt.toml
━━━━━━━━━
edition
─────────
2018
━━━━━━━━━
─────────┬──────
edition2018
─────────┴──────
```
```shell
> open rustfmt.toml | inc edition
━━━━━━━━━
edition
─────────
2019
━━━━━━━━━
─────────┬──────
edition2019
─────────┴──────
```
```shell
> open Cargo.toml | get package.version
0.1.3
0.15.1
```
```shell
> open Cargo.toml | inc package.version --major | get package.version
1.0.0
```
```shell
> open Cargo.toml | inc package.version --minor | get package.version
0.2.0
0.16.0
```
```shell
> open Cargo.toml | inc package.version --patch | get package.version
0.1.4
```
0.15.2
```

View File

@ -6,24 +6,25 @@ Use `last` to retrieve the last "n" rows of a table. `last` has a required amoun
```shell
> ps | last 1
━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
pid │ name │ status │ cpu
─────┼─────────────┼─────────┼───────────────────
121 │ loginwindow │ Running │ 0.000000000000000
━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
─────────┬─────────────
pid 167
name │ loginwindow
status │ Running
cpu │ 0.0000
mem │ 461.2 MB
virtual │ 7.2 GB
─────────┴─────────────
```
```shell
> ps | last 5
━━━┯━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
# │ pid │ name │ status │ cpu
───┼─────┼────────────────┼─────────┼───────────────────
0360CommCenter │ Running │ 0.000000000000000
1358distnoted │ Running │ 0.000000000000000
2356UserEventAgent │ Running │ 0.000000000000000
3354 │ cfprefsd │ Running │ 0.000000000000000
4121 │ loginwindow │ Running │ 0.000000000000000
━━━┷━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
───┬─────┬─────────────────┬─────────┬────────┬──────────┬─────────
# │ pid │ name │ status │ cpu │ mem │ virtual
───┼─────┼────────────────┼─────────┼────────┼───────────────────
0334knowledge-agent │ Running │ 0.0000 │ 53.7 MB │ 6.7 GB
1332UserEventAgent │ Running │ 0.0000 │ 22.1 MB │ 6.6 GB
2326cfprefsd │ Running │ 0.0000 │ 8.1 MB │ 5.6 GB
3325 │ coreauthd │ Running │ 0.0000 │ 9.7 MB │ 5.0 GB
4167 │ loginwindow │ Running │ 0.0000 │ 461.2 MB │ 7.2 GB
───┴─────┴─────────────────┴─────────┴────────┴──────────┴─────────
```

View File

@ -1,13 +1,17 @@
# lines
This command takes a string from a pipeline as input, and returns a table where each line of the input string is a row in the table. Empty lines are ignored. This command is capable of feeding other commands, such as `nth`, with its output.
## Usage
```shell
> [input-command] | lines
```
## Examples
Basic usage:
```shell
> printf "Hello\nWorld!\nLove, nushell." | lines
━━━┯━━━━━━━━━━━━━━━━
@ -20,6 +24,7 @@ Basic usage:
```
One useful application is piping the contents of file into `lines`. This example extracts a certain line from a given file.
```shell
> cat lines.md | lines | nth 6
## Examples

View File

@ -63,6 +63,7 @@ To get the average of the file sizes in a directory, simply pipe the size column
```
```shell
> ls | get size | math max
───┬──────────
# │
───┼──────────

View File

@ -3,40 +3,73 @@
This command returns the nth row of a table, starting from 0.
If the number given is less than 0 or more than the number of rows, nothing is returned.
### Usage
## Usage
```shell
> [input-command] | nth <row number> ...args
```
### Parameters:
## Parameters
* `<row number>` the number of the row to return
* `args`: Optionally return more rows
## Examples
```shell
> ls
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
# │ name │ typereadonly │ size │ accessed │ modified
───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
0 │ Cargo.toml │ File │ │ 239 B 2 minutes ago │ 2 minutes ago
1.git │ Directory │ │ 4.1 KB │ 2 minutes ago │ 2 minutes ago
2.gitignore │ File 19 B 2 minutes ago │ 2 minutes ago
3src │ Directory │ │ 4.1 KB │ 2 minutes ago │ 2 minutes ago
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
────┬────────────────────┬──────┬──────────┬──────────────
# │ name type │ size │ modified
───┼────────────────────┼──────────────────────────────
0 │ CODE_OF_CONDUCT.md │ File │ 3.4 KB │ 53 mins ago
1 CONTRIBUTING.md │ File │ 1.3 KB │ 6 mins ago
2 Cargo.lock │ File │ 113.3 KB53 mins ago
3 Cargo.toml │ File │ 4.6 KB │ 53 mins ago
4 │ LICENSE │ File │ 1.1 KB │ 3 months ago
5 │ Makefile.toml │ File │ 449 B │ 5 months ago
6 │ README.md │ File │ 15.8 KB │ 2 mins ago
7 │ TODO.md │ File │ 0 B │ 53 mins ago
8 │ assets │ Dir │ 128 B │ 5 months ago
9 │ build.rs │ File │ 78 B │ 4 months ago
10 │ crates │ Dir │ 704 B │ 53 mins ago
11 │ debian │ Dir │ 352 B │ 5 months ago
12 │ docker │ Dir │ 288 B │ 3 months ago
13 │ docs │ Dir │ 192 B │ 53 mins ago
14 │ features.toml │ File │ 632 B │ 4 months ago
15 │ images │ Dir │ 160 B │ 5 months ago
16 │ rustfmt.toml │ File │ 16 B │ 5 months ago
17 │ src │ Dir │ 128 B │ 1 day ago
18 │ target │ Dir │ 160 B │ 5 days ago
19 │ tests │ Dir │ 192 B │ 3 months ago
────┴────────────────────┴──────┴──────────┴──────────────
```
```shell
> ls | nth 0
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified
───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
──────────┬────────────────────
name │ CODE_OF_CONDUCT.md
type │ File
size │ 3.4 KB
modified │ 54 mins ago
──────────┴────────────────────
```
```shell
> ls | nth 0 2
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
# │ name │ typereadonly │ size │ accessed │ modified
───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
0 │ Cargo.toml │ File │ │ 239 B 2 minutes ago │ 2 minutes ago
2.gitignore │ File │ │ 19 B 2 minutes ago │ 2 minutes ago
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
───┬────────────────────┬──────┬──────────┬─────────────
# │ name type │ size │ modified
───┼────────────────────┼──────┼──────────┼─────────────
0 │ CODE_OF_CONDUCT.md │ File │ 3.4 KB │ 54 mins ago
1Cargo.lock │ File │ 113.3 KB │ 54 mins ago
───┴────────────────────┴──────┴──────────┴─────────────
```
```shell
> ls | nth 5
```
──────────┬───────────────
name │ Makefile.toml
type │ File
size │ 449 B
modified │ 5 months ago
──────────┴───────────────
```

View File

@ -18,6 +18,9 @@ Loads a file into a cell, convert it to table if possible (avoid by appending `-
Age: 50
Telephone: 99521080
Country: Germany
```
```shell
> open user.yaml
━━━┯━━━━━━━━━┯━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━
# │ Name │ Age │ Telephone │ Country
@ -26,6 +29,9 @@ Loads a file into a cell, convert it to table if possible (avoid by appending `-
1 │ Michael │ 4244002010 │ Spain
2 │ Will │ 5099521080 │ Germany
━━━┷━━━━━━━━━┷━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━
```
```shell
> open user.yaml --raw
- Name: Peter
Age: 30
@ -44,25 +50,28 @@ Loads a file into a cell, convert it to table if possible (avoid by appending `-
```shell
> cat user.json
[
{
"Name": "Peter",
"Age": 30,
"Telephone": 88204828,
"Country": "Singapore"
},
{
"Name": "Michael",
"Age": 42,
"Telephone": 44002010,
"Country": "Spain"
},
{
"Name": "Will",
"Age": 50,
"Telephone": 99521080,
"Country": "Germany"
}
{
"Name": "Peter",
"Age": 30,
"Telephone": 88204828,
"Country": "Singapore"
},
{
"Name": "Michael",
"Age": 42,
"Telephone": 44002010,
"Country": "Spain"
},
{
"Name": "Will",
"Age": 50,
"Telephone": 99521080,
"Country": "Germany"
}
]
```
```shell
> open user.json
━━━┯━━━━━━━━━┯━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━
# │ Name │ Age │ Telephone │ Country
@ -71,25 +80,28 @@ Loads a file into a cell, convert it to table if possible (avoid by appending `-
1 │ Michael │ 4244002010 │ Spain
2 │ Will │ 5099521080 │ Germany
━━━┷━━━━━━━━━┷━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━
```
```shell
> open user.json --raw
[
{
"Name": "Peter",
"Age": 30,
"Telephone": 88204828,
"Country": "Singapore"
},
{
"Name": "Michael",
"Age": 42,
"Telephone": 44002010,
"Country": "Spain"
},
{
"Name": "Will",
"Age": 50,
"Telephone": 99521080,
"Country": "Germany"
}
{
"Name": "Peter",
"Age": 30,
"Telephone": 88204828,
"Country": "Singapore"
},
{
"Name": "Michael",
"Age": 42,
"Telephone": 44002010,
"Country": "Spain"
},
{
"Name": "Will",
"Age": 50,
"Telephone": 99521080,
"Country": "Germany"
}
]
```
```

View File

@ -4,72 +4,66 @@ Pivots the table contents so rows become columns and columns become rows.
## Examples
```sh
```shell
> ls docs
━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified
───┼────────────────────┼───────────┼──────────┼────────┼─────────────┼─────────────
0 │ docs/commands │ Directory │ 4.1 KB │ an hour ago │ an hour ago
1 │ docs/docker.md │ File │ │ 7.0 KB │ an hour ago │ a day ago
2 │ docs/philosophy.md │ File │ │ 896 B an hour ago │ a day ago
━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━
───┬────────────────────┬──────┬────────┬─────────────
# │ name │ type │ size │ modified
───┼────────────────────┼──────────────┼─────────────
0 │ docs/commands │ Dir │ 2.7 KB │ 53 mins ago
1 │ docs/docker.md │ File │ 7.0 KB │ 40 mins ago
2 │ docs/philosophy.md │ File 912 B │ 54 mins ago
───┴────────────────────┴──────┴────────┴─────────────
```
```shell
> ls docs | pivot
━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━
───┬──────────┬───────────────┬────────────────┬────────────────────
# │ Column0 │ Column1 │ Column2 │ Column3
───┼──────────┼───────────────┼────────────────┼────────────────────
0 │ name │ docs/commands │ docs/docker.md │ docs/philosophy.md
1type │ Directory │ File │ File
2readonly
3size │ 4.1 KB │ 7.0 KB │ 896 B
4 │ accessed │ an hour ago │ an hour ago │ an hour ago
5 │ modified │ an hour ago │ a day ago │ a day ago
━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━
1type │ Dir │ File │ File
2size 2.7 KB │ 7.0 KB │ 912 B
3modified │ 53 mins ago │ 40 mins ago │ 55 mins ago
───┴──────────┴───────────────┴────────────────┴────────────────────
```
Use `--header-row` to treat the first row as column names:
```shell
> ls docs | pivot --header-row
━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━
───┬───────────────┬────────────────┬────────────────────
# │ docs/commands │ docs/docker.md │ docs/philosophy.md
───┼───────────────┼────────────────┼────────────────────
0 │ Directory │ File │ File
1
2 4.1 KB │ 7.0 KB │ 896 B
3 │ an hour ago │ an hour ago │ an hour ago
4 │ an hour ago │ a day ago │ a day ago
━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━
0 │ Dir │ File │ File
12.7 KB │ 7.0 KB912 B
253 mins ago │ 40 mins ago │ 55 mins ago
───┴───────────────┴────────────────┴────────────────────
```
Use `--ignore-titles` to prevent pivoting the column names into values:
```shell
> ls docs | pivot --ignore-titles
━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━
───┬───────────────┬────────────────┬────────────────────
# │ Column0 │ Column1 │ Column2
───┼───────────────┼────────────────┼────────────────────
0 │ docs/commands │ docs/docker.md │ docs/philosophy.md
1 │ Directory │ File │ File
2
3 4.1 KB │ 7.0 KB │ 896 B
4 │ an hour ago │ an hour ago │ an hour ago
5 │ an hour ago │ a day ago │ a day ago
━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━
1 │ Dir │ File │ File
22.7 KB │ 7.0 KB912 B
354 mins ago │ 41 mins ago │ 56 mins ago
───┴───────────────┴────────────────┴────────────────────
```
Additional arguments are used as column names:
```shell
> ls docs | pivot foo bar baz
━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━
───┬──────────┬───────────────┬────────────────┬────────────────────
# │ foo │ bar │ baz │ Column3
───┼──────────┼───────────────┼────────────────┼────────────────────
0 │ name │ docs/commands │ docs/docker.md │ docs/philosophy.md
1type │ Directory │ File │ File
2readonly
3size │ 4.1 KB │ 7.0 KB │ 896 B
4 │ accessed │ 2 hours ago │ 2 hours ago │ 2 hours ago
5 │ modified │ 2 hours ago │ a day ago │ a day ago
━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━
1type │ Dir │ File │ File
2size 2.7 KB │ 7.0 KB │ 912 B
3modified │ 55 mins ago │ 41 mins ago │ 56 mins ago
───┴──────────┴───────────────┴────────────────┴────────────────────
```

View File

@ -1,7 +1,9 @@
# prepend
This command prepends the given row to the front of the table
**Note**:
- `prepend` does not change a file itself. If you want to save your changes, you need to run the `save` command
- if you want to add something containing a whitespace character, you need to put it in quotation marks
@ -12,7 +14,7 @@ Let's complete this table with the missing continents:
```shell
> open continents.txt | lines
━━━┯━━━━━━━━━━━━━━━
# │ <value>
# │
───┼───────────────
0 │ Africa
1 │ South America
@ -27,7 +29,7 @@ You can add a new row at the top by using `prepend`:
```shell
> open continents.txt | lines | prepend Asia
━━━┯━━━━━━━━━━━━━━━
# │ <value>
# │
───┼───────────────
0 │ Asia
1 │ Africa
@ -43,7 +45,7 @@ It's not possible to add multiple rows at once, so you'll need to call `prepend`
```shell
> open continents.txt | lines | prepend Asia | prepend "North America"
━━━┯━━━━━━━━━━━━━━━
# │ <value>
# │
───┼───────────────
0 │ North America
1 │ Asia

View File

@ -8,7 +8,6 @@ Syntax: `ps`
```shell
> ps
...
━━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
# │ pid │ name │ status │ cpu
────┼───────┼────────────────────────────────────────────────────────────────────┼─────────┼───────────────────
@ -22,4 +21,4 @@ Syntax: `ps`
686268 │ firefox.exe │ Running │ 0.000000000000000
698972 │ nu_plugin_ps.exe │ Running │ 58.00986000000000
━━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
```
```

View File

@ -15,6 +15,9 @@ This command removes or rejects the columns passed to it.
3 │ abaracadabra.txt │ File │ │ 401 B │ a month ago │ a month ago │ a month ago
4 │ youshouldeatmorecereal.txt │ File │ │ 768 B │ a month ago │ a month ago │ a month ago
━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━
```
```shell
> ls | reject readonly
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━
# │ name │ type │ size │ created │ accessed │ modified
@ -25,6 +28,9 @@ This command removes or rejects the columns passed to it.
3 │ abaracadabra.txt │ File │ 401 B │ a month ago │ a month ago │ a month ago
4 │ youshouldeatmorecereal.txt │ File │ 768 B │ a month ago │ a month ago │ a month ago
━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━
```
```shell
> ls | reject readonly accessed
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━
# │ name │ type │ size │ created │ modified

View File

@ -15,6 +15,9 @@ This command reverses the order of the elements in a sorted table.
3 │ youshouldeatmorecereal.txt │ File │ │ 768 B │ 30 seconds ago │ now
4 │ zeusiscrazy.txt │ File │ │ 556 B │ 22 minutes ago │ 18 minutes ago
━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━
```
```shell
> ls | sort-by name | reverse
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified
@ -38,6 +41,9 @@ This command reverses the order of the elements in a sorted table.
3 │ zeusiscrazy.txt │ File │ │ 556 B │ 22 minutes ago │ 19 minutes ago
4 │ youshouldeatmorecereal.txt │ File │ │ 768 B │ a minute ago │ 26 seconds ago
━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━
```
```shell
> ls | sort-by size | reverse
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified

View File

@ -4,7 +4,7 @@ This command saves the contents of the pipeline to a file. Use this in combinati
Syntax: `save (path) {flags}`
### Parameters:
## Parameters
* `(path)` the path to save contents to
@ -27,4 +27,4 @@ Or you can format it in supported formats using one of the `to` commands:
> ls | where type == File | select name | to csv | save filenames
```
`filename.csv` and `filenames` are both `csv` formatted files. Nu auto-converts the format if a supported file extension is given.
`filename.csv` and `filenames` are both `csv` formatted files. Nu auto-converts the format if a supported file extension is given.

View File

@ -15,6 +15,9 @@ This command displays only the column names passed on to it.
3 │ abaracadabra.txt │ File │ │ 401 B │ a month ago │ a month ago │ a month ago
4 │ youshouldeatmorecereal.txt │ File │ │ 768 B │ a month ago │ a month ago │ a month ago
━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━
```
```shell
> ls | select name
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ name
@ -40,6 +43,9 @@ The order in which you put the column names matters:
3 │ File │ abaracadabra.txt │ 401 B
4 │ File │ youshouldeatmorecereal.txt │ 768 B
━━━┷━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━
```
```shell
> ls | select size type name
━━━┯━━━━━━━━┯━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ size │ type │ name

View File

@ -4,7 +4,7 @@ Lists all the active nu shells with a number/index, a name and the path. Also ma
## Examples
```
```shell
> shells
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path
@ -15,7 +15,7 @@ Lists all the active nu shells with a number/index, a name and the path. Also ma
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
```
```shell
/> shells
━━━┯━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path

View File

@ -2,32 +2,36 @@
Shuffles the rows in a random order.
## Examples -
## Examples
Passing the same input to shuffle multiple times gives different results -
Passing the same input to shuffle multiple times gives different results -
```
echo [ a b c d ] | shuffle
```shell
> echo [ a b c d ] | shuffle
───┬───
0 │ a
1 │ c
2 │ d
3 │ b
───┴───
echo [ a b c d ] | shuffle
───┬───
0 │ c
1 │ b
2d
3a
───┴───
echo [ a b c d ] | shuffle
───┬───
0 │ c
1 │ b
2 │ a
3 │ d
0 │ a
1 │ c
2 │ d
3 │ b
───┴───
```
```shell
> echo [ a b c d ] | shuffle
───┬───
0c
1b
2 │ d
3 │ a
───┴───
```
```shell
> echo [ a b c d ] | shuffle
───┬───
0 │ c
1 │ b
2 │ a
3 │ d
───┴───
```

View File

@ -2,7 +2,7 @@
This commands gives word count statistics on any text.
## Examples -
## Examples
```shell
> open lalala.txt | size
@ -11,6 +11,9 @@ This commands gives word count statistics on any text.
───────┼───────┼───────┼────────────
4107272
━━━━━━━┷━━━━━━━┷━━━━━━━┷━━━━━━━━━━━━
```
```shell
> open the_mysterious_affair_at_styles.txt | size
━━━━━━━┯━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━
lines │ words │ chars │ max length

View File

@ -1,14 +1,17 @@
# skip-while
Skips rows while the condition matches.
Skips rows while the condition matches.
## Usage
```shell
> [input-command] | skip-while <condition>
```
## Examples
If we open a file with a list of contacts, we get all of the contacts.
If we open a file with a list of contacts, we get all of the contacts.
```shell
> open contacts.csv | sort-by "last name"
───┬────────────┬───────────┬──────────────────
@ -21,7 +24,8 @@ If we open a file with a list of contacts, we get all of the contacts.
───┴────────────┴───────────┴──────────────────
```
To exclude skip contacts with last names startin with 'A' or 'B', use skip-while:
To exclude skip contacts with last names starting with 'A' or 'B', use skip-while:
```shell
> open contacts.csv | sort-by "last name" | skip-while "last name" < "C"
───┬────────────┬───────────┬──────────────────
@ -33,6 +37,7 @@ To exclude skip contacts with last names startin with 'A' or 'B', use skip-while
```
Note that the order of input rows matters. Once a single row does not match the condition, all following rows are included in the output, whether or not they match the condition:
```shell
> open contacts.csv | skip-while "last name" < "C"
───┬────────────┬───────────┬──────────────────
@ -43,4 +48,5 @@ Note that the order of input rows matters. Once a single row does not match the
2 │ Francis │ Davis │ davis@email.com
───┴────────────┴───────────┴──────────────────
```
See the `where` command to filter each individual row by a condition, regardless of order.
See the `where` command to filter each individual row by a condition, regardless of order.

View File

@ -1,14 +1,17 @@
# skip
Skips the first 'n' rows of a table.
Skips the first 'n' rows of a table.
## Usage
```shell
> [input-command] | skip (n)
```
## Examples
If we open a file with a list of contacts, we get all of the contacts.
If we open a file with a list of contacts, we get all of the contacts.
```shell
> open contacts.csv
───┬─────────┬──────┬─────────────────
@ -22,6 +25,7 @@ If we open a file with a list of contacts, we get all of the contacts.
```
To ignore the first 2 contacts, we can `skip` them.
```shell
> open contacts.csv | skip 2
───┬─────────┬──────┬─────────────────
@ -30,4 +34,4 @@ To ignore the first 2 contacts, we can `skip` them.
0 │ Chris │ Doe │ doe.3@email.com
1 │ Francis │ Doe │ doe.4@email.com
───┴─────────┴──────┴─────────────────
```
```

View File

@ -5,11 +5,10 @@ The `sort-by` command sorts the table being displayed in the terminal by a chose
`sort-by` takes multiple arguments (being the names of columns) sorting by each argument in order.
## Examples -
## Examples
```shell
/home/example> ls | sort-by size
> ls | sort-by size
━━━┯━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified
───┼──────┼──────┼──────────┼────────┼────────────────┼────────────────
@ -25,7 +24,7 @@ The `sort-by` command sorts the table being displayed in the terminal by a chose
```
```shell
/home/example> ls | sort-by size name
> ls | sort-by size name
━━━┯━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified
───┼──────┼──────┼──────────┼────────┼────────────────┼────────────────
@ -39,8 +38,8 @@ The `sort-by` command sorts the table being displayed in the terminal by a chose
7 │ b │ File │ │ 349 B │ 36 minutes ago │ 36 minutes ago
```
```
/home/example> ls | sort-by accessed
```shell
> ls | sort-by accessed
━━━┯━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified
───┼──────┼──────┼──────────┼────────┼────────────────┼────────────────
@ -53,4 +52,4 @@ The `sort-by` command sorts the table being displayed in the terminal by a chose
6 │ ad │ File │ │ 18 B │ 5 minutes ago │ 5 minutes ago
7 │ az │ File │ │ 18 B │ 5 minutes ago │ 5 minutes ago
━━━┷━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━
```
```

View File

@ -4,12 +4,12 @@ splits contents across multiple columns via the separator.
Syntax: `split column <separator> ...args{flags}`
### Parameters
## Parameters
* `<separator>`: string that denotes what separates columns
* `args`: column names to give the new columns. If not specified they will be set to `Column1` `Column2` ...
### Flags
## Flags
--collapse-empty
Removes empty columns
@ -35,7 +35,7 @@ We can build a table from it using the `split column` command
```shell
> open coordinates.txt | lines | split column " | "
━━━┯━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━
───┬─────────────────────┬──────────────────────┬────────────────────
# │ Column1 │ Column2 │ Column3
───┼─────────────────────┼──────────────────────┼────────────────────
0 │ 0.12643678160919541 │ 0.6851851851851852 │ 0.273972602739726
@ -48,14 +48,14 @@ We can build a table from it using the `split column` command
7 │ 0.9310344827586207 │ 1.1296296296296295 │ 0.7123287671232876
8 │ 0.3448275862068966 │ 0.018518518518518517 │ 0.6575342465753424
9 │ 1.0459770114942528 │ 1.0925925925925926 │ 0.6164383561643836
━━━┷━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━
───┴─────────────────────┴──────────────────────┴────────────────────
```
And give names to the columns
```shell
> open coordinates.txt | lines | split column " | " x y z
━━━┯━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━
───┬─────────────────────┬──────────────────────┬────────────────────
# │ x │ y │ z
───┼─────────────────────┼──────────────────────┼────────────────────
0 │ 0.12643678160919541 │ 0.6851851851851852 │ 0.273972602739726
@ -68,5 +68,5 @@ And give names to the columns
7 │ 0.9310344827586207 │ 1.1296296296296295 │ 0.7123287671232876
8 │ 0.3448275862068966 │ 0.018518518518518517 │ 0.6575342465753424
9 │ 1.0459770114942528 │ 1.0925925925925926 │ 0.6164383561643836
━━━┷━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━
```
───┴─────────────────────┴──────────────────────┴────────────────────
```

View File

@ -4,7 +4,8 @@ splits contents over multiple rows via the separator.
Syntax: `split row <separator>`
### Parameters:
## Parameters
* `<separator>` the character that denotes what separates rows
## Examples
@ -14,21 +15,20 @@ We can build a table from a file that looks like this
```shell
> open table.txt
4, 0, 2, 0, 7, 8
```
using the `split row` command.
```shell
open table.txt | split row ", "
━━━┯━━━━━━━━━
# │ <value>
───┼─────────
───┬───
# │
───┼───
04
10
22
30
47
58
━━━┷━━━━━━━━━
```
───┴───
```

View File

@ -4,11 +4,11 @@ Opens each file/directory/URL using the default application.
Syntax: `start ...args{flags}`
### Parameters
## Parameters
* `args`: a list of space-separated files to open
### Flags
## Flags
-a --application <string>
Specifies the application used for opening the files/directories/urls
@ -16,11 +16,13 @@ Syntax: `start ...args{flags}`
## Example
Open `index.html` in the system's default browser (cross platform):
```shell
> start index.html
```
Open `index.html` in Firefox (specific path for OSX):
```shell
start index.html -a /Applications/Firefox.app
```

View File

@ -12,6 +12,9 @@ Applies the subcommand to a value or a table.
0 │ X │ filesystem │ /home/TUX/stuff/expr/stuff
1 │ │ filesystem │ /
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | str upcase path
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path
@ -19,6 +22,9 @@ Applies the subcommand to a value or a table.
0 │ X │ filesystem │ /HOME/TUX/STUFF/EXPR/STUFF
1 │ │ filesystem │ /
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | str downcase path
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path
@ -26,6 +32,9 @@ Applies the subcommand to a value or a table.
0 │ X │ filesystem │ /home/tux/stuff/expr/stuff
1 │ │ filesystem │ /
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | str substring "21, 99" path
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path
@ -33,6 +42,9 @@ Applies the subcommand to a value or a table.
0 │ X │ filesystem │ stuff
1 │ │ filesystem │
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | str substring "6," path
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path
@ -40,27 +52,24 @@ Applies the subcommand to a value or a table.
0 │ X │ filesystem │ TUX/stuff/expr/stuff
1 │ │ filesystem │
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> echo "1, 2, 3" | split row "," | str to-int | math sum
━━━━━━━━━
<value>
─────────
6
━━━━━━━━━
6
```
```shell
> echo "nu" | str capitalize
━━━━━━━━━
<value>
─────────
Nu
━━━━━━━━━
Nu
```
```shell
> echo "Nu " | str trim
━━━━━━━━━
<value>
─────────
Nu
━━━━━━━━━
Nu
```
```shell
> shells | str find-replace "TUX" "skipper" path
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path
@ -68,5 +77,4 @@ Applies the subcommand to a value or a table.
0 │ X │ filesystem │ /home/skipper/stuff/expr/stuff
1 │ │ filesystem │ /
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

View File

@ -6,27 +6,45 @@ This command gives information about the system nu is running on.
```shell
> sys
━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━
host │ cpu │ disks │ mem │ net │ battery
────────────────┼────────────────┼─────────────────┼────────────────┼──────────────────┼────────────────
[table: 1 row][table: 1 row][table: 3 rows][table: 1 row][table: 18 rows][table: 1 row]
━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━
> sys | get host
━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━
name │ release │ hostname │ arch │ uptime │ sessions
────────┼─────────┼──────────────┼────────┼────────────────┼──────────────────
Darwin │ 18.7.0 │ C02Y437GJGH6 │ x86_64 │ [table: 1 row][table: 17 rows]
━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━
> sys | get cpu
━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
cores │ current ghz │ min ghz │ max ghz
───────┼───────────────────┼───────────────────┼───────────────────
12 │ 2.600000000000000 │ 2.600000000000000 │ 2.600000000000000
━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
> sys | get mem
━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━
total │ free │ swap total │ swap free
──────────────────────────────────────────
34.4 GB │ 545.0 MB │ 2.1 GB │ 723.0 MB
━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━
─────────┬─────────────────────────────────────────
host [row 7 columns]
cpu │ [row cores current ghz max ghz min ghz]
disks [table 4 rows]
mem │ [row free swap free swap total total]
net │ [table 19 rows]
battery │ [table 1 rows]
─────────┴─────────────────────────────────────────
```
```shell
> sys | get host
──────────┬──────────────────────────────────────────────────────────────────────────────────────────────────
name │ Darwin
release │ 19.5.0
version │ Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64
hostname │ Josephs-MacBook-Pro.local
arch │ x86_64
uptime │ 5:10:12:33
sessions │ [table 2 rows]
──────────┴──────────────────────────────────────────────────────────────────────────────────────────────────
```
```shell
> sys | get cpu
─────────────┬────────
cores │ 16
current ghz │ 2.4000
min ghz │ 2.4000
max ghz │ 2.4000
─────────────┴────────
```
```shell
> sys | get mem
────────────┬─────────
total │ 68.7 GB
free │ 11.1 GB
swap total │ 0 B
swap free │ 0 B
────────────┴─────────
```

View File

@ -14,31 +14,29 @@ As of writing this, the only metadata returned includes:
```shell
> open README.md | tags
━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
span │ anchor
────────────────┼──────────────────────────────────────────────────
[table: 1 row] │ /Users/danielh/Projects/github/nushell/README.md
━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
────────┬──────────────────────────────────────────────────
span [row end start]
anchor │ /Users/danielh/Projects/github/nushell/README.md
────────┴──────────────────────────────────────────────────
```
```shell
> open README.md | tags | get span
━━━━━━━┯━━━━━
start │ end
───────┼─────
514
━━━━━━━┷━━━━━
───────┬────
start │ 5
end │ 14
───────┴────
```
```shell
> ls | tags | first 3 | get span
━━━┯━━━━━━━┯━━━━━
───┬───────┬─────
# │ start │ end
───┼───────┼─────
002
102
202
━━━┷━━━━━━━┷━━━━━
───┴───────┴─────
```
## Reference

View File

@ -1,7 +1,8 @@
# textview config
The configuration for textview, which is used to autoview text files, uses [bat](https://docs.rs/bat/0.15.4/bat/struct.PrettyPrinter.html). The textview configurtion will **not** use any existing `bat` configuration you may have.
### Configuration Points and Defaults
## Configuration Points and Defaults
| config point | definition | implemented |
| - | - | - |
| term_width | The character width of the terminal (default: autodetect) | yes |
@ -22,7 +23,8 @@ The configuration for textview, which is used to autoview text files, uses [bat]
| highlight_range | Specify a range of lines that should be highlighted (default: none). This can be called multiple times to highlight more than one range of lines. | no |
| theme | Specify the highlighting theme (default: OneHalfDark) | yes |
### Example textview confguration for `config.toml`
## Example textview confguration for `config.toml`
```toml
[textview]
term_width = "default"
@ -40,16 +42,21 @@ paging_mode = "QuitIfOneScreen"
pager = "less"
theme = "TwoDark"
```
### Example Usage
```
## Example Usage
```shell
> open src/main.rs
```
```
```shell
> cat some_file.txt | textview
```
```
```shell
> fetch https://www.jonathanturner.org/feed.xml --raw
```
### Help
## Help
For a more detailed description of the configuration points that textview uses, please visit the `bat` repo at https://github.com/sharkdp/bat

View File

@ -13,6 +13,9 @@ Converts table data into csv text.
1 │ │ filesystem │ /home/shaurya/Pictures
2 │ │ filesystem │ /home/shaurya/Desktop
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | to csv
,name,path
X,filesystem,/home/shaurya
@ -66,6 +69,9 @@ X,filesystem,/home/shaurya
│ │ │ │ OMYACARB 1T │ │ │ │ │ │ │
│ │ │ │ CG BPA 25 NO │ │ │ │ │ │ │
━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━
```
```shell
> open caco3_plastics.csv | to csv
importer,shipper,tariff_item,name,origin,shipped_at,arrived_at,net_weight,fob_price,cif_price,cif_per_net_weight
PLASTICOS RIVAL CIA LTDA,S A REVERTE,2509000000,CARBONATO DE CALCIO TIPO CALCIPORE 160 T AL,SPAIN,18/03/2016,17/04/2016,"81,000.00","14,417.58","18,252.34",0.23
@ -79,7 +85,7 @@ QUIMICOS ANDINOS QUIMANDI S.A.,SIBELCO COLOMBIA SAS,3824909999,CARBONATO DE CALC
TIGRE ECUADOR S.A. ECUATIGRE,OMYA ANDINA S.A NIT 830.027.386-6,3824909999,CARBONATO DE CALCIO RECUBIERTO CON ACIDO ESTEARICO OMYACARB 1T CG BPA 25 NO,COLOMBIA,01/01/1900,28/10/2016,"66,000.00","11,748.00","18,216.00",0.28
```
To use a character other than ',' to separate records, use `--separator` :
To use a character other than ',' to separate records, use `--separator`:
```shell
> shells
@ -90,6 +96,9 @@ To use a character other than ',' to separate records, use `--separator` :
1 │ │ filesystem │ /home/shaurya/Pictures
2 │ │ filesystem │ /home/shaurya/Desktop
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | to csv --separator ';'
;name,path
X;filesystem;/home/shaurya
@ -103,7 +112,7 @@ Newlines '\n' are not acceptable separators.
Note that separators are currently provided as strings and need to be wrapped in quotes.
It is also considered an error to use a separator greater than one char :
It is also considered an error to use a separator greater than one char:
```shell
> open pets.txt | from-csv --separator '123'

View File

@ -17,6 +17,9 @@ Converts table data into JSON text.
1 │ │ filesystem │ /home/shaurya/Pictures
2 │ │ filesystem │ /home/shaurya/Desktop
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | to json
[{" ":"X","name":"filesystem","path":"/home/shaurya"},{" ":" ","name":"filesystem","path":"/home/shaurya/Pictures"},{" ":" ","name":"filesystem","path":"/home/shaurya/Desktop"}]
```
@ -28,10 +31,15 @@ Converts table data into JSON text.
────────────────
[table: 1 row]
━━━━━━━━━━━━━━━━
```
```shell
> open sgml_description.json | to json
{"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","Height":10,"GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"Sections":[101,102],"GlossSee":"markup"}}}}}
```
We can also convert formats !
We can also convert formats!
```shell
> open jonathan.xml
━━━━━━━━━━━━━━━━
@ -39,6 +47,9 @@ We can also convert formats !
────────────────
[table: 1 row]
━━━━━━━━━━━━━━━━
```
```shell
> open jonathan.xml | to json
{"rss":[{"channel":[{"title":["Jonathan Turner"]},{"link":["http://www.jonathanturner.org"]},{"link":[]},{"item":[{"title":["Creating crossplatform Rust terminal apps"]},{"description":["<p><img src=\"/images/pikachu.jpg\" alt=\"Pikachu animation in Windows\" /></p>\n\n<p><em>Look Mom, Pikachu running in Windows CMD!</em></p>\n\n<p>Part of the adventure is not seeing the way ahead and going anyway.</p>\n"]},{"pubDate":["Mon, 05 Oct 2015 00:00:00 +0000"]},{"link":["http://www.jonathanturner.org/2015/10/off-to-new-adventures.html"]},{"guid":["http://www.jonathanturner.org/2015/10/off-to-new-adventures.html"]}]}]}]}
```

View File

@ -13,6 +13,9 @@ Converts table data into toml text.
1 │ │ filesystem │ /home/shaurya/Pictures
2 │ │ filesystem │ /home/shaurya/Desktop
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | to toml
[[]]
" " = "X"
@ -28,7 +31,6 @@ path = "/home/shaurya/Pictures"
" " = " "
name = "filesystem"
path = "/home/shaurya/Desktop"
```
```shell
@ -38,6 +40,9 @@ path = "/home/shaurya/Desktop"
────────────────┼──────────────────┼────────────────
[table: 1 row][table: 1 row][table: 1 row]
━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━
```
```shell
> open cargo_sample.toml | to toml
[dependencies]
ansi_term = "0.11.0"
@ -107,5 +112,4 @@ edition = "2018"
license = "ISC"
name = "nu"
version = "0.1.1"
```

View File

@ -13,10 +13,12 @@ Converts table data into tsv text.
1 │ │ filesystem │ /home/shaurya/Pictures
2 │ │ filesystem │ /home/shaurya/Desktop
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━
> shells | to tsv
name path
X filesystem /home/shaurya
```
```shell
> shells | to tsv
name path
X filesystem /home/shaurya
```
```shell
@ -65,6 +67,9 @@ X filesystem /home/shaurya
│ │ │ │ OMYACARB 1T │ │ │ │ │ │ │
│ │ │ │ CG BPA 25 NO │ │ │ │ │ │ │
━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━
```
```shell
> open caco3_plastics.tsv | to tsv
importer shipper tariff_item name origin shipped_at arrived_at net_weight fob_price cif_price cif_per_net_weight
PLASTICOS RIVAL CIA LTDA S A REVERTE 2509000000 CARBONATO DE CALCIO TIPO CALCIPORE 160 T AL SPAIN 18/03/2016 17/04/2016 81,000.00 14,417.58 18,252.34 0.23
@ -76,5 +81,4 @@ PICA PLASTICOS INDUSTRIALES C.A. OMYA ANDINA S.A 3824909999 CARBONAT
PLASTIQUIM S.A. OMYA ANDINA S.A NIT 830.027.386-6 3824909999 CARBONATO DE CALCIO RECUBIERTO CON ACIDO ESTEARICO OMYA CARB 1T CG BBS 1000 COLOMBIA 01/01/1900 25/10/2016 33,000.00 6,270.00 9,999.00 0.30
QUIMICOS ANDINOS QUIMANDI S.A. SIBELCO COLOMBIA SAS 3824909999 CARBONATO DE CALCIO RECUBIERTO COLOMBIA 01/11/2016 03/11/2016 52,000.00 8,944.00 13,039.05 0.25
TIGRE ECUADOR S.A. ECUATIGRE OMYA ANDINA S.A NIT 830.027.386-6 3824909999 CARBONATO DE CALCIO RECUBIERTO CON ACIDO ESTEARICO OMYACARB 1T CG BPA 25 NO COLOMBIA 01/01/1900 28/10/2016 66,000.00 11,748.00 18,216.00 0.28
```

View File

@ -13,6 +13,9 @@ Converts table data into [url-encoded text](https://url.spec.whatwg.org/#applica
1 │ │ filesystem │ /home/shaurya/Pictures
2 │ │ filesystem │ /home/shaurya/Desktop
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | to url
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ value
@ -30,6 +33,9 @@ Converts table data into [url-encoded text](https://url.spec.whatwg.org/#applica
──────────┼────────┼──────┼────────
baguette │ comté │ ham │ butter
━━━━━━━━━━┷━━━━━━━━┷━━━━━━┷━━━━━━━━
```
```shell
> open sample.url | to url
bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter
```

View File

@ -13,6 +13,9 @@ Converts table data into yaml text.
1 │ │ filesystem │ /home/shaurya/Pictures
2 │ │ filesystem │ /home/shaurya/Desktop
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | to yaml
---
- " ": X
@ -33,6 +36,9 @@ Converts table data into yaml text.
────────────────────┼────────────────┼─────────────────┼───────┼─────────────────┼─────────────────
Visual Studio 2017[table: 1 row][table: 5 rows] │ │ [table: 2 rows][table: 2 rows]
━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━
```
```shell
> open appveyor.yml | to yaml
---
image: Visual Studio 2017

View File

@ -28,6 +28,9 @@ Converts table data into a string or binary. The target format is specified as a
1 │ │ filesystem │ /home/shaurya/Pictures
2 │ │ filesystem │ /home/shaurya/Desktop
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | to csv
,name,path
X,filesystem,/home/shaurya
@ -42,6 +45,9 @@ X,filesystem,/home/shaurya
──────────┼────────┼──────┼────────
baguette │ comté │ ham │ butter
━━━━━━━━━━┷━━━━━━━━┷━━━━━━┷━━━━━━━━
```
```shell
> open sample.url | to url
bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter
```

View File

@ -7,18 +7,26 @@ Trim leading and following whitespace from text data
```shell
> echo " Hello world"
Hello world
```
```shell
> echo " Hello world" | trim
Hello world
```
Trim can also be passed a list or table of text, for which it will trim each item individually.
It will fail if any element in the list or table is not of type String.
```shell
> open greetings.json | to json
[" hi ", " hello ", " wassup "]
```
```shell
> open greetings.json | trim | to json
["hi", "hello", "wassup"]
```
```shell
> cargo search shells --limit 10 | lines | parse "{crate_name} = {version} #{description}"
━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@ -36,6 +44,9 @@ It will fail if any element in the list or table is not of type String.
9 │ rust_keylock_shell │ "0.10.0" │ Shell access to the rust-keylock. rust-keylock is a password manager with goals
│ │ │ to be Secure, …
━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> cargo search shells --limit 10 | lines | parse "{crate_name} = {version} #{description}" | trim
━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ crate_name │ version │ description

View File

@ -6,7 +6,7 @@ Returns unique rows or values from a dataset.
Given a file `test.csv`
```
```csv
first_name,last_name,rusty_at,type
Andrés,Robalino,10/11/2013,A
Andrés,Robalino,10/11/2013,A
@ -14,7 +14,7 @@ Jonathan,Turner,10/12/2013,B
Yehuda,Katz,10/11/2013,A
```
```
```shell
> `open test.csv | uniq`
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━
# │ first_name │ last_name │ rusty_at │ type
@ -25,10 +25,10 @@ Yehuda,Katz,10/11/2013,A
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━
```
```
```shell
> `open test.csv | get type | uniq`
━━━┯━━━━━━━━━
# │ <value>
# │
───┼─────────
0 │ A
1 │ B
@ -36,14 +36,15 @@ Yehuda,Katz,10/11/2013,A
```
### Counting
`--count` or `-c` is the flag to output a `count` column.
```
```shell
> `open test.csv | get type | uniq -c`
───┬───────┬───────
# │ value │ count
# │ value │ count
───┼───────┼───────
0 │ A │ 3
1 │ B │ 2
0 │ A │ 3
1 │ B │ 2
───┴───────┴───────
```
```

View File

@ -15,6 +15,9 @@ Updates an existing column on a table. First parameter is the column to update a
3 │ abaracadabra.txt │ File │ │ 401 B │ a day ago │ a day ago
4 │ youshouldeatmorecereal.txt │ File │ │ 768 B │ a day ago │ a day ago
━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━
```
```shell
> ls | update modified neverrrr
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified
@ -35,6 +38,9 @@ Updates an existing column on a table. First parameter is the column to update a
0 │ X │ filesystem │ /home/username/stuff/expr/stuff
1 │ │ filesystem │ /
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```
```shell
> shells | update " " X | update path /
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━
# │ │ name │ path

View File

@ -6,9 +6,7 @@ Outputs the nushell version.
```shell
> version
━━━━━━━━━
version
─────────
0.6.0
━━━━━━━━━
─────────┬────────
version │ 0.15.1
─────────┴────────
```

View File

@ -3,6 +3,7 @@
This command filters the content of a table based on a condition passed as a parameter, which must be a boolean expression making use of any of the table columns. Other commands such as `ls` are capable of feeding `where` with their output through pipelines.
Where has two general forms:
- `where <column_name> <comparison> <value>`
- `where <column_name>`
@ -18,6 +19,7 @@ In the first form, `where` is passed a column name that the filter will run agai
- `==` (equal)
Strings have two additional operators:
- `=~` (fuzzy match to allow)
- `!~` (fuzzy match to not allow)
@ -36,6 +38,7 @@ Dates can also be compared using the duration types. For example, `where accesse
Where with the form `| where readonly` is used to check boolean values. For example, the command `ls --full | where readonly` will list only those files that are readonly.
## Usage
```shell
> [input-command] | where [condition]
```
@ -44,47 +47,58 @@ Where with the form `| where readonly` is used to check boolean values. For exam
```shell
> ls | where size > 4kb
━━━┯━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━
# │ name │ type │ size │ created │ accessed │ modified
───┼────────────┼──────┼─────────┼─────────────┼─────────────┼─────────────
0 │ Cargo.lock │ File │ 87.2 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago
1README.md │ File │ 19.5 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago
2Cargo.toml │ File │ 4.7 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago
━━━┷━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━
───┬────────────┬──────┬──────────┬─────────────
# │ name │ type │ size │ modified
───┼────────────┼──────┼──────────┼─────────────
0 │ Cargo.lock │ File │ 113.3 KB │ 53 mins ago
1Cargo.toml │ File │ 4.6 KB │ 53 mins ago
2README.md │ File │ 15.8 KB │ 2 mins ago
───┴────────────┴──────┴──────────┴─────────────
```
```shell
> ps | where cpu > 0
━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
# │ pid │ name │ status │ cpu
───┼───────┼───────────────────────┼──────────┼───────────────────
0 1546 │ Xorg │ Sleeping │ 10.65405000000000
1 1769 │ gnome-shell │ Sleeping │ 5.271094000000000
2 2153 │ gnome-terminal-server │ Sleeping │ 5.193664000000000
313556 │ nu_plugin_psSleeping │ 40.70250000000000
━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
───┬───────┬──────────────────┬─────────┬────────┬──────────┬─────────
# │ pid │ name │ status │ cpu │ mem │ virtual
───┼───────┼──────────────────┼─────────┼────────┼───────────────────
017917 │ nu_plugin_core_p │ Running │ 4.1678 │ 2.1 MB │ 4.8 GB
114717 │ Discord Helper ( │ Running │ 1.6842 │ 371.9 MB │ 8.0 GB
214713 │ Discord Helper │ Running │ 0.2099 │ 27.8 MB │ 5.8 GB
314710 │ DiscordRunning │ 0.0883 │ 105.4 MB │ 7.0 GB
49643 │ Terminal │ Running │ 4.0313 │ 266.4 MB │ 7.6 GB
57864 │ Microsoft.Python │ Running │ 0.9828 │ 340.9 MB │ 8.0 GB
624402 │ Code Helper (Ren │ Running │ 1.0644 │ 337.3 MB │ 8.4 GB
724401 │ Code Helper (Ren │ Running │ 1.0031 │ 593.5 MB │ 8.6 GB
8519 │ EmojiFunctionRow │ Running │ 0.2063 │ 52.7 MB │ 7.5 GB
9376 │ CommCenter │ Running │ 0.1620 │ 30.0 MB │ 6.5 GB
───┴───────┴──────────────────┴─────────┴────────┴──────────┴─────────
```
```shell
> ls | where accessed <= 1w
━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━
# │ name │ type │ size │ accessed │ modified
───┼──────────────────────────┼──────────┼───────────┼────────────
0 │ Cargo.toml │ File │ 4.7 KB │ 2 days ago │ 2 days ago
1target │ Directory │ 4.1 KB │ 2 days ago │ 2 days ago
2Makefile.toml │ File │ 449 B │ 4 days ago │ 4 days ago
3README.md │ File │ 19.5 KB │ 2 days ago │ 2 days ago
4Cargo.lock │ File │ 170.7 KB │ 2 days ago │ 2 days ago
5crates │ Directory │ 4.1 KB │ 2 days ago │ 2 days ago
6TODO.md │ File │ 1.3 KB │ 2 days ago │ 2 days ago
━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━
> ls -f | where accessed <= 1w
───┬────────────────────┬──────┬────────┬──────────┬───────────┬─────────────┬───────┬──────────┬──────────────┬─────────────┬─────────────
# │ name │ type │ target │ readonly │ mode │ uid │ group │ size │ created │ accessed │ modified
───┼────────────────────┼──────┼────────┼──────────┼───────────┼─────────────┼───────┼──────────┼──────────────┼─────────────┼─────────────
0 │ CODE_OF_CONDUCT.md │ File │ No │ rw-r--r-- │ josephlyons │ staff │ 3.4 KB │ 52 mins ago 52 secs ago │ 52 mins ago
1CONTRIBUTING.md │ File │ │ No │ rw-r--r-- │ josephlyons │ staff │ 1.3 KB │ 52 mins ago │ 4 mins ago 4 mins ago
2Cargo.lock │ File No │ rw-r--r-- │ josephlyons │ staff │ 113.3 KB │ 52 mins ago │ 52 mins ago │ 52 mins ago
3Cargo.toml │ File │ No │ rw-r--r-- │ josephlyons │ staff │ 4.6 KB │ 52 mins ago │ 52 mins ago │ 52 mins ago
4README.md │ File │ No │ rw-r--r-- │ josephlyons │ staff │ 15.8 KB │ 52 mins ago 1 min ago │ 1 min ago
5TODO.md │ File │ │ No │ rw-r--r-- │ josephlyons │ staff │ 0 B │ 52 mins ago 52 mins ago │ 52 mins ago
6crates │ Dir │ │ No │ rwxr-xr-x │ josephlyons │ staff │ 704 B │ 4 months ago │ 52 mins ago │ 52 mins ago
7 │ docs │ Dir │ │ No │ rwxr-xr-x │ josephlyons │ staff │ 192 B │ 5 months ago │ 52 mins ago │ 52 mins ago
8 │ src │ Dir │ │ No │ rwxr-xr-x │ josephlyons │ staff │ 128 B │ 5 months ago │ 1 day ago │ 1 day ago
9 │ target │ Dir │ │ No │ rwxr-xr-x │ josephlyons │ staff │ 160 B │ 5 days ago │ 5 days ago │ 5 days ago
───┴────────────────────┴──────┴────────┴──────────┴───────────┴─────────────┴───────┴──────────┴──────────────┴─────────────┴─────────────
```
```shell
> ls | where name =~ "yml"
━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━
name type │ size │ accessed │ modified
─────────────┼──────┼───────┼────────────┼────────────
.gitpod.yml │ File │ 780 B │ a week ago │ a week ago
━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━
> ls -a | where name =~ "yml"
──────────┬─────────────
name │ .gitpod.yml
type │ File
size │ 866 B
modified │ 1 month ago
──────────┴─────────────
```

View File

@ -18,58 +18,64 @@ Usage:
`which` finds the location of an executable:
```shell
/home/bob> which python
━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━
arg │ pathbuiltin
────────┼─────────────────┼─────────
python │ /usr/bin/python │ No
━━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━━
/home/bob> which cargo
━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━
arg │ path │ builtin
───────┼────────────────────────────┼─────────
cargo │ /home/bob/.cargo/bin/cargo │ No
━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━
> which python
─────────┬─────────────────
arg │ python
path │ /usr/bin/python
builtin │ No
─────────┴─────────────────
```
```shell
> which cargo
─────────┬────────────────────────────
arg │ cargo
path │ /home/bob/.cargo/bin/cargo
builtin │ No
─────────┴────────────────────────────
```
`which` will identify nushell commands:
```shell
/home/bob> which ls
━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━
arg │ path │ builtin
─────┼──────────────────────────┼─────────
ls │ nushell built-in command │ Yes
━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━
/home/bob> which which
━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━
arg │ path │ builtin
───────┼──────────────────────────┼─────────
which │ nushell built-in command │ Yes
━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━
> which ls
─────────┬──────────────────────────
arg │ ls
path │ nushell built-in command
builtin │ Yes
─────────┴──────────────────────────
```
```shell
> which which
─────────┬──────────────────────────
arg │ which
path │ nushell built-in command
builtin │ Yes
─────────┴──────────────────────────
```
Passing the `all` flag identifies all instances of a command or binary
```shell
/home/bob> which ls --all
━━━┯━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━
> which ls --all
───┬─────┬──────────────────────────┬─────────
# │ arg │ path │ builtin
───┼─────┼──────────────────────────┼─────────
0 │ ls │ nushell built-in command │ Yes
1 │ ls │ /usr/bin/ls │ No
━━━┷━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━
1 │ ls │ /bin/ls │ No
───┴─────┴──────────────────────────┴─────────
```
`which` will also identify local binaries
```shell
/home/bob> touch foo
/home/bob> chmod +x foo
/home/bob> which ./foo
━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━
arg │ path │ builtin
───────┼───────────────┼─────────
./foo │ /home/bob/foo │ No
━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━
> touch foo
> chmod +x foo
> which ./foo
─────────┬────────────────────────────────
arg │ ./foo
path │ /Users/josephlyons/Desktop/foo
builtin │ No
─────────┴────────────────────────────────
```

View File

@ -13,15 +13,17 @@ Syntax: `wrap <column>`
`wrap` will give a name to a column of `<value>` data:
```shell
/home/chris> ls | get name
> ls | get name
───┬──────────────
# │ <value>
# │
───┼──────────────
0 │ americas.csv
1 │ iso.csv
───┴──────────────
```
/home/chris> ls | get name | wrap filename
```shell
> ls | get name | wrap filename
───┬──────────────
# │ filename
───┼──────────────
@ -30,10 +32,10 @@ Syntax: `wrap <column>`
───┴──────────────
```
`wrap` will encapsulate rows as embedded tables :
`wrap` will encapsulate rows as embedded tables:
```shell
/home/chris> ls | select name type size
> ls | select name type size
───┬──────────────┬──────┬─────────
# │ name │ type │ size
───┼──────────────┼──────┼─────────
@ -41,7 +43,7 @@ Syntax: `wrap <column>`
1 │ iso.csv │ File │ 20.8 KB
───┴──────────────┴──────┴─────────
/home/chris> ls | select name type size | each {wrap details}
> ls | select name type size | each {wrap details}
───┬────────────────
# │ details
───┼────────────────
@ -50,12 +52,11 @@ Syntax: `wrap <column>`
───┴────────────────
```
`wrap` will encapsulate a whole table as an embedded table :
`wrap` will encapsulate a whole table as an embedded table:
```shell
/home/chris> ls | wrap files
> ls | wrap files
───────┬────────────────
files │ [table 2 rows]
───────┴────────────────
```