moved folders

This commit is contained in:
Fernando Herrera
2022-02-07 19:23:12 +00:00
parent fdce6c49ab
commit dbcadbc12c
294 changed files with 0 additions and 63 deletions

25
docs/commands/README.md Normal file
View File

@ -0,0 +1,25 @@
# How do I get started?
Pick any command from the checklist and write a comment acknowledging you started work.
## Instructions for documenting a Nu command of your choosing
Name the file after the command, like so:
`command.md`
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?
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):
* Examples of using the command (max creativity welcomed!)
* Description of the command.
* Command usage.
## Anything else?
Of course! (These are drafts) so feel free to leave feedback and suggestions in the same file.
Happy Documenting.

32
docs/commands/alias.md Normal file
View File

@ -0,0 +1,32 @@
# 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 them to your config.
Syntax: `alias <name> = <body>`
The command expects two parameters:
* The name of the alias
* The body of the alias
## Examples
Define a custom `myecho` command as an alias:
```shell
> alias myecho = echo
> myecho "hello world"
hello world
```
The suggested help command works!
```shell
> myecho -h
Usage:
> myecho {flags}
flags:
-h, --help: Display this help message
```

25
docs/commands/all.md Normal file
View File

@ -0,0 +1,25 @@
# all?
Find if the table rows matches the condition.
## Usage
```shell
> all? <condition> {flags}
```
## Parameters
* `<condition>` the condition that must match
## Flags
* -h, --help: Display this help message
## Examples
Find if services are running
```shell
> echo [[status]; [UP] [UP]] | all? status == UP
```
Check that all values are even
```shell
> echo [2 4 6 8] | all? ($it mod 2) == 0
```

View File

@ -0,0 +1,20 @@
# ansi strip
strip ansi escape sequences from string
## Usage
```shell
> ansi strip ...args {flags}
```
## Parameters
* ...args: optionally, remove ansi sequences by column paths
## Flags
* -h, --help: Display this help message
## Examples
strip ansi escape sequences from string
```shell
> echo [(ansi gb) 'hello' (ansi reset)] | str collect | ansi strip
```

88
docs/commands/ansi.md Normal file
View File

@ -0,0 +1,88 @@
# ansi
Output ANSI codes to change color.
For escape sequences:
Escape: `\x1b[` is not required for --escape parameter
Format: `#(;#)m`
Example: 1;31m for bold red or 2;37;41m for dimmed white fg with red bg
There can be multiple text formatting sequence numbers
separated by a ; and ending with an m where the # is of the
following values:
attributes
* 0 reset / normal display
* 1 bold or increased intensity
* 2 faint or decreased intensity
* 3 italic on (non-mono font)
* 4 underline on
* 5 slow blink on
* 6 fast blink on
* 7 reverse video on
* 8 nondisplayed (invisible) on
* 9 strike-through on
```
foreground/bright colors background/bright colors
30/90 black 40/100 black
31/91 red 41/101 red
32/92 green 42/102 green
33/93 yellow 43/103 yellow
34/94 blue 44/104 blue
35/95 magenta 45/105 magenta
36/96 cyan 46/106 cyan
37/97 white 47/107 white
https://en.wikipedia.org/wiki/ANSI_escape_code
```
OSC: `\x1b]` is not required for --osc parameter
Example: `echo [(ansi -o '0') 'some title' (char bel)] | str collect`
Format:
* 0 Set window title and icon name
* 1 Set icon name
* 2 Set window title
* 4 Set/read color palette
* 9 iTerm2 Grown notifications
* 10 Set foreground color (x11 color spec)
* 11 Set background color (x11 color spec)
* ... others
## Usage
```shell
> ansi (code) <subcommand> {flags}
```
## Subcommands
* ansi strip - strip ansi escape sequences from string
## Parameters
* `(code)` the name of the code to use like 'green' or 'reset' to reset the color
## Flags
* -h, --help: Display this help message
* -e, --escape <any>: escape sequence without the escape character(s)
* -o, --osc <any>: operating system command (ocs) escape sequence without the escape character(s)
## Examples
Change color to green
```shell
> ansi green
```
Reset the color
```shell
> ansi reset
```
Use ansi to color text (rb = red bold, gb = green bold, pb = purple bold)
```shell
> echo [(ansi rb) Hello " " (ansi gb) Nu " " (ansi pb) World] | str collect
```
Use ansi to color text (rb = red bold, gb = green bold, pb = purple bold)
```shell
> echo [(ansi -e '3;93;41m') Hello (ansi reset) " " (ansi gb) Nu " " (ansi pb) World] | str collect
```

25
docs/commands/any.md Normal file
View File

@ -0,0 +1,25 @@
# any?
Find if the table rows matches the condition.
## Usage
```shell
> any? <condition> {flags}
```
## Parameters
* `<condition>` the condition that must match
## Flags
* -h, --help: Display this help message
## Examples
Find if a service is not running
```shell
> echo [[status]; [UP] [DOWN] [UP]] | any? status == DOWN
```
Check if any of the values is odd
```shell
> echo [2 4 1 6 8] | any? ($it mod 2) == 1
```

105
docs/commands/append.md Normal file
View File

@ -0,0 +1,105 @@
# append
Append a row to the table.
## Examples
Given the following text file `cities.txt` containing cities:
```shell
Canberra
London
Nairobi
Washington
```
And getting back a Nu table:
```shell
> open cities.txt | lines
───┬────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
───┴────────────
```
Add the city named `Beijing` like so:
```shell
> open cities.txt | lines | append Beijing
───┬────────────
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 use `append` multiple times:
```shell
> open cities.txt | lines | append Beijing | append "Buenos Aires"
───┬──────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
4 │ Beijing
5 │ Buenos Aires
───┴──────────────
```
So far we have been working with a table without a column, which leaves us with plain rows. Let's `wrap` the plain rows into a column called `city` and save it as a json file called `cities.json`:
Before we save, let's check how it looks after wrapping:
```shell
open cities.txt | lines | wrap city
───┬────────────
# │ city
───┼────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
───┴────────────
```
And save:
`> open cities.txt | lines | wrap city | save cities.json`
Since we will be working with rows that have a column, appending like before won't quite give us back what we want:
```shell
> open cities.json | append Guayaquil
───┬────────────
# │ city
───┼────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
───┴────────────
───┬───────────
4 │ Guayaquil
───┴───────────
```
We append a row literal directly:
```shell
> open cities.json | append [[city]; [Guayaquil]]
───┬────────────
# │ city
───┼────────────
0 │ Canberra
1 │ London
2 │ Nairobi
3 │ Washington
4 │ Guayaquil
───┴────────────
```

View File

@ -0,0 +1,25 @@
# autoenv trust
Trust a .nu-env file in the current or given directory
## Usage
```shell
> autoenv trust (dir) {flags}
```
## Parameters
* `(dir)` Directory to allow
## Flags
* -h, --help: Display this help message
## Examples
Allow .nu-env file in current directory
```shell
> autoenv trust
```
Allow .nu-env file in directory foo
```shell
> autoenv trust foo
```

View File

@ -0,0 +1,25 @@
# autoenv untrust
Untrust a .nu-env file in the current or given directory
## Usage
```shell
> autoenv untrust (dir) {flags}
```
## Parameters
* `(dir)` Directory to disallow
## Flags
* -h, --help: Display this help message
## Examples
Disallow .nu-env file in current directory
```shell
> autoenv untrust
```
Disallow .nu-env file in directory foo
```shell
> autoenv untrust foo
```

34
docs/commands/autoenv.md Normal file
View File

@ -0,0 +1,34 @@
# autoenv
Manage directory specific environment variables and scripts.
Create a file called .nu-env in any directory and run 'autoenv trust' to let nushell load it when entering the directory.
The .nu-env file has the same format as your $HOME/nu/config.toml file. By loading a .nu-env file the following applies:
* - environment variables (section \"[env]\") are loaded from the .nu-env file. Those env variables only exist in this directory (and children directories)
* - the \"startup\" commands are run when entering the directory
* - the \"on_exit\" commands are run when leaving the directory
## Usage
```shell
> autoenv <subcommand> {flags}
```
## Subcommands
* autoenv trust - Trust a .nu-env file in the current or given directory
* autoenv untrust - Untrust a .nu-env file in the current or given directory
## Flags
* -h, --help: Display this help message
## Examples
Example .nu-env file
```shell
> cat .nu-env
```
startup = ["echo ...entering the directory", "echo 1 2 3"]
on_exit = ["echo ...leaving the directory"]
[env]
mykey = "myvalue"

59
docs/commands/autoview.md Normal file
View File

@ -0,0 +1,59 @@
# autoview
Print the content of the pipeline as a table or list.
It is the implied or default viewer when none is provided.
When reading a single value, a table or a list, `autoview` will attempt to view it.
When reading a string that originally comes from a source file it will attempt
to use `textview`.
When reading a binary file it will attempt to display its content as hexadecimal
numbers and the corresponding characters.
`-h`, `--help`
Display help message.
## Examples
In all following examples `autoview` can be removed with no change in the output.
The use of `autoview` at the end of the pipeline is implied when no viewer is
explicitly used.
```shell
> which nu | get path | autoview
/home/me/.cargo/bin/nu
```
```shell
> ls | autoview
────┬────────────────────┬──────┬─────────┬──────────────
# │ name │ type │ size │ modified
────┼────────────────────┼──────┼─────────┼──────────────
0 │ README.md │ File │ 932 B │ 19 hours ago
1 │ alias.md │ File │ 2.0 KB │ 19 hours ago
2 │ append.md │ File │ 1.4 KB │ 19 hours ago
...
82 │ wrap.md │ File │ 1.8 KB │ 19 hours ago
────┴────────────────────┴──────┴─────────┴──────────────
```
```shell
> echo "# Hi" "## Section" "Some text" | save file.md
> open file.md | autoview
# Hi
## Section
Some text
```
`autoview` will use `textview` to colorize the text based on the file format.
The style used by `textview` can be configured in `config.toml`.
```shell
> open --raw (which nu | get path) | autoview
...
126d1c0: 64 31 66 37 62 30 31 63 36 2e 31 31 38 2e 6c 6c d1f7b01c6.118.ll
126d1d0: 76 6d 2e 34 34 38 37 35 37 31 32 34 39 35 33 39 vm.4487571249539
126d1e0: 34 34 30 34 30 39 00 61 6e 6f 6e 2e 30 30 61 63 440409.anon.00ac
126d1f0: 37 32 65 36 37 66 32 31 39 34 62 32 32 61 61 63 72e67f2194b22aac
126d200: 62 35 39 37 33 36 30 62 64 31 39 38 2e 31 36 2e b597360bd198.16.
...
```

View File

@ -0,0 +1,26 @@
# benchmark
Runs a block and returns the time it took to execute it.
## Usage
```shell
> benchmark <block> {flags}
```
## Parameters
* `<block>` the block to run and benchmark
## Flags
* -h, --help: Display this help message
* -p, --passthrough <block>: Display the benchmark results and pass through the block's output
## Examples
Benchmarks a command within a block
```shell
> benchmark { sleep 500ms }
```
Benchmarks a command within a block and passes its output through
```shell
> echo 45 | benchmark { sleep 500ms } --passthrough {}
```

View File

@ -0,0 +1,14 @@
# binaryview
Autoview of binary data.
## Usage
```shell
> binaryview {flags}
```
## Flags
* -h, --help: Display this help message
* -l, --lores: use low resolution output mode
* -s, --skip <integer>: skip x number of bytes
* -b, --bytes <integer>: show y number of bytes

View File

@ -0,0 +1,20 @@
# build-string
Builds a string from the arguments.
## Usage
```shell
> build-string ...args {flags}
```
## Parameters
* ...args: all values to form into the string
## Flags
* -h, --help: Display this help message
## Examples
Builds a string from a string and a number, without spaces between them
```shell
> build-string 'foo' 3
```

204
docs/commands/cal.md Normal file
View File

@ -0,0 +1,204 @@
# cal
Use `cal` to display a calendar.
## Flags
* `-y`, `--year`: Display the year column
* `-q`, `--quarter`: Display the quarter column
* `-m`, `--month`: Display the month column
* `--full-year` \<integer>: Display a year-long calendar for the specified year
* `--week-start` \<string>: Display the calendar with the specified day as the first day of the week
* `--month-names`: Display the month names instead of integers
## Examples
```shell
> cal
───┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
# │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
───┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
0 │ │ │ │ │ │ 12
13456789
210111213141516
317181920212223
424252627282930
531 │ │ │ │ │ │
───┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
```
```shell
> cal -yqm --full-year 2020
────┬──────┬─────────┬───────┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
# │ year │ quarter │ month │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
────┼──────┼─────────┼───────┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
0202011 │ │ │ │ 1234
1202011567891011
220201112131415161718
320201119202122232425
4202011262728293031
5202012 │ │ │ │ │ │ │ 1
62020122345678
72020129101112131415
820201216171819202122
920201223242526272829
102020131234567
11202013891011121314
1220201315161718192021
1320201322232425262728
14202013293031 │ │ │ │
15202024 │ │ │ │ 1234
16202024567891011
1720202412131415161718
1820202419202122232425
192020242627282930 │ │
20202025 │ │ │ │ │ │ 12
212020253456789
2220202510111213141516
2320202517181920212223
2420202524252627282930
2520202531 │ │ │ │ │ │
26202026 │ │ 123456
2720202678910111213
2820202614151617181920
2920202621222324252627
30202026282930 │ │ │ │
31202037 │ │ │ │ 1234
32202037567891011
3320203712131415161718
3420203719202122232425
35202037262728293031
36202038 │ │ │ │ │ │ │ 1
372020382345678
382020389101112131415
3920203816171819202122
4020203823242526272829
412020383031 │ │ │ │ │
42202039 │ │ │ 12345
432020396789101112
4420203913141516171819
4520203920212223242526
4620203927282930 │ │ │
472020410 │ │ │ │ │ 123
48202041045678910
49202041011121314151617
50202041018192021222324
51202041025262728293031
5220204111234567
532020411891011121314
54202041115161718192021
55202041122232425262728
5620204112930 │ │ │ │ │
572020412 │ │ │ 12345
5820204126789101112
59202041213141516171819
60202041220212223242526
6120204122728293031 │ │
────┴──────┴─────────┴───────┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
```
```shell
> cal -yqm --full-year 2020 --month-names
────┬──────┬─────────┬───────────┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
# │ year │ quarter │ month │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
────┼──────┼─────────┼───────────┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
020201 │ january │ │ │ │ 1234
120201 │ january │ 567891011
220201 │ january │ 12131415161718
320201 │ january │ 19202122232425
420201 │ january │ 262728293031
520201 │ february │ │ │ │ │ │ │ 1
620201 │ february │ 2345678
720201 │ february │ 9101112131415
820201 │ february │ 16171819202122
920201 │ february │ 23242526272829
1020201 │ march │ 1234567
1120201 │ march │ 891011121314
1220201 │ march │ 15161718192021
1320201 │ march │ 22232425262728
1420201 │ march │ 293031 │ │ │ │
1520202 │ april │ │ │ │ 1234
1620202 │ april │ 567891011
1720202 │ april │ 12131415161718
1820202 │ april │ 19202122232425
1920202 │ april │ 2627282930 │ │
2020202 │ may │ │ │ │ │ │ 12
2120202 │ may │ 3456789
2220202 │ may │ 10111213141516
2320202 │ may │ 17181920212223
2420202 │ may │ 24252627282930
2520202 │ may │ 31 │ │ │ │ │ │
2620202 │ june │ │ 123456
2720202 │ june │ 78910111213
2820202 │ june │ 14151617181920
2920202 │ june │ 21222324252627
3020202 │ june │ 282930 │ │ │ │
3120203 │ july │ │ │ │ 1234
3220203 │ july │ 567891011
3320203 │ july │ 12131415161718
3420203 │ july │ 19202122232425
3520203 │ july │ 262728293031
3620203 │ august │ │ │ │ │ │ │ 1
3720203 │ august │ 2345678
3820203 │ august │ 9101112131415
3920203 │ august │ 16171819202122
4020203 │ august │ 23242526272829
4120203 │ august │ 3031 │ │ │ │ │
4220203 │ september │ │ │ 12345
4320203 │ september │ 6789101112
4420203 │ september │ 13141516171819
4520203 │ september │ 20212223242526
4620203 │ september │ 27282930 │ │ │
4720204 │ october │ │ │ │ │ 123
4820204 │ october │ 45678910
4920204 │ october │ 11121314151617
5020204 │ october │ 18192021222324
5120204 │ october │ 25262728293031
5220204 │ november │ 1234567
5320204 │ november │ 891011121314
5420204 │ november │ 15161718192021
5520204 │ november │ 22232425262728
5620204 │ november │ 2930 │ │ │ │ │
5720204 │ december │ │ │ 12345
5820204 │ december │ 6789101112
5920204 │ december │ 13141516171819
6020204 │ december │ 20212223242526
6120204 │ december │ 2728293031 │ │
────┴──────┴─────────┴───────────┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
```
```shell
> cal -ym --full-year 2303 --month-names | where month == "june"
───┬──────┬───────┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
# │ year │ month │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
───┼──────┼───────┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
02303 │ june │ │ 123456
12303 │ june │ 78910111213
22303 │ june │ 14151617181920
32303 │ june │ 21222324252627
42303 │ june │ 282930 │ │ │ │
───┴──────┴───────┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
```
```shell
> cal -my --full-year 2020 --month-names | default friday 0 | where friday == 13
───┬──────┬──────────┬────────┬────────┬─────────┬───────────┬──────────┬────────┬──────────
# │ year │ month │ sunday │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday
───┼──────┼──────────┼────────┼────────┼─────────┼───────────┼──────────┼────────┼──────────
02020 │ march │ 891011121314
12020 │ november │ 891011121314
───┴──────┴──────────┴────────┴────────┴─────────┴───────────┴──────────┴────────┴──────────
```
```shell
> cal -ymq --month-names --week-start monday
───┬──────┬─────────┬───────┬────────┬─────────┬───────────┬──────────┬────────┬──────────┬────────
# │ year │ quarter │ month │ monday │ tuesday │ wednesday │ thursday │ friday │ saturday │ sunday
───┼──────┼─────────┼───────┼────────┼─────────┼───────────┼──────────┼────────┼──────────┼────────
020202 │ june │ 1234567
120202 │ june │ 891011121314
220202 │ june │ 15161718192021
320202 │ june │ 22232425262728
420202 │ june │ 2930 │ │ │ │ │
───┴──────┴─────────┴───────┴────────┴─────────┴───────────┴──────────┴────────┴──────────┴────────
```

33
docs/commands/cd.md Normal file
View File

@ -0,0 +1,33 @@
# cd
If you didn't already know, the `cd` command is very simple. It stands for 'change directory' and it does exactly that. It changes the current directory to the one specified. If no directory is specified, it takes you to the home directory. Additionally, using `cd ..` takes you to the parent directory.
## Examples
```shell
/home/username> cd Desktop
/home/username/Desktop> now your current directory has been changed
```
```shell
/home/username/Desktop/nested/folders> cd ..
/home/username/Desktop/nested> cd ..
/home/username/Desktop> cd ../Documents/school_related
/home/username/Documents/school_related> cd ../../..
/home/>
```
```shell
/home/username/Desktop/super/duper/crazy/nested/folders> cd
/home/username> cd ../../usr
/usr> cd
/home/username>
```
Using `cd -` will take you to the previous directory:
```shell
/home/username/Desktop/super/duper/crazy/nested/folders> cd
/home/username> cd -
/home/username/Desktop/super/duper/crazy/nested/folders> cd
```

38
docs/commands/char.md Normal file
View File

@ -0,0 +1,38 @@
# char
Output special characters (e.g., 'newline').
## Usage
```shell
> char (character) ...args {flags}
```
## Parameters
* `(character)` the name of the character to output
* ...args: multiple Unicode bytes
## Flags
* -h, --help: Display this help message
* -l, --list: List all supported character names
* -u, --unicode: Unicode string i.e. 1f378
## Examples
Output newline
```shell
> char newline
```
Output prompt character, newline and a hamburger character
```shell
> echo (char prompt) (char newline) (char hamburger)
```
Output Unicode character
```shell
> char -u 1f378
```
Output multi-byte Unicode character
```shell
> char -u 1F468 200D 1F466 200D 1F466
```

View File

@ -0,0 +1,17 @@
# chart bar
Bar charts
## Usage
```shell
> chart bar (columns) {flags}
```
## Parameters
* `(columns)` the columns to chart [x-axis y-axis]
## Flags
* -h, --help: Display this help message
* -a, --acc: accumulate values
* -u, --use <column path>: column to use for evaluation
* -f, --format <string>: Specify date and time formatting

View File

@ -0,0 +1,17 @@
# chart line
Line charts
## Usage
```shell
> chart line (columns) {flags}
```
## Parameters
* `(columns)` the columns to chart [x-axis y-axis]
## Flags
* -h, --help: Display this help message
* -a, --acc: accumulate values
* -u, --use <column path>: column to use for evaluation
* -f, --format <string>: Specify date and time formatting

15
docs/commands/chart.md Normal file
View File

@ -0,0 +1,15 @@
# chart
Displays charts.
## Usage
```shell
> chart <subcommand> {flags}
```
## Subcommands
* chart bar - Bar charts
* chart line - Line charts
## Flags
* -h, --help: Display this help message

17
docs/commands/clear.md Normal file
View File

@ -0,0 +1,17 @@
# clear
Clears the terminal.
## Usage
```shell
> clear {flags}
```
## Flags
* -h, --help: Display this help message
## Examples
Clear the screen
```shell
> clear
```

22
docs/commands/clip.md Normal file
View File

@ -0,0 +1,22 @@
# clip
Copy the contents of the pipeline to the copy/paste buffer.
## Usage
```shell
> clip {flags}
```
## Flags
* -h, --help: Display this help message
## Examples
Save text to the clipboard
```shell
> echo 'secret value' | clip
```
Save numbers to the clipboard
```shell
> random integer 10000000..99999999 | clip
```

35
docs/commands/compact.md Normal file
View File

@ -0,0 +1,35 @@
# compact
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]
```
## Examples
Let's say we have a table like this:
```shell
> open contacts.json
━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━
# │ name │ email
───┼──────────┼──────────────────
0 │ paul │ paul@example.com
1 │ andres │
2 │ jonathan │
━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━
```
`compact` allows us to filter out rows with empty `email` column:
```shell
> open contacts.json | compact email
━━━━━━┯━━━━━━━━━━━━━━━━━━
name │ email
──────┼──────────────────
paul │ paul@example.com
━━━━━━┷━━━━━━━━━━━━━━━━━━
```

View File

@ -0,0 +1,17 @@
# config clear
clear the config
## Usage
```shell
> config clear {flags}
```
## Flags
* -h, --help: Display this help message
## Examples
Clear the config (be careful!)
```shell
> config clear
```

View File

@ -0,0 +1,20 @@
# config get
Gets a value from the config
## Usage
```shell
> config get <get> {flags}
```
## Parameters
* `<get>` value to get from the config
## Flags
* -h, --help: Display this help message
## Examples
Get the current startup commands
```shell
> config get startup
```

View File

@ -0,0 +1,17 @@
# config path
return the path to the config file
## Usage
```shell
> config path {flags}
```
## Flags
* -h, --help: Display this help message
## Examples
Get the path to the current config file
```shell
> config path
```

View File

@ -0,0 +1,20 @@
# config remove
Removes a value from the config
## Usage
```shell
> config remove <remove> {flags}
```
## Parameters
* `<remove>` remove a value from the config
## Flags
* -h, --help: Display this help message
## Examples
Remove the startup commands
```shell
> config remove startup
```

View File

@ -0,0 +1,44 @@
# config set
Sets a value in the config
## Usage
```shell
> config set <key> <value> {flags}
```
## Parameters
- `<key>` variable name to set
- `<value>` value to use
## Flags
- -h, --help: Display this help message
## Examples
Set auto pivoting
```shell
> config set pivot_mode always
```
Set line editor options
```shell
> config set line_editor [[edit_mode, completion_type]; [emacs circular]]
```
Set coloring options
```shell
> config set color_config [[header_align header_color]; [left white_bold]]
```
Set nested options
```shell
> config set color_config.header_color white
```

View File

@ -0,0 +1,20 @@
# config set_into
Sets a value in the config
## Usage
```shell
> config set_into <set_into> {flags}
```
## Parameters
* `<set_into>` sets a variable from values in the pipeline
## Flags
* -h, --help: Display this help message
## Examples
Store the contents of the pipeline as a path
```shell
> echo ['/usr/bin' '/bin'] | config set_into path
```

53
docs/commands/config.md Normal file
View File

@ -0,0 +1,53 @@
# config
Configuration management.
Syntax: `config {flags}`
## Flags
load <file path shape>
load the config from the path give
set <any shape>
set a value in the config, eg) set variable value
set_into <member shape>
sets a variable from values in the pipeline
get <any shape>
get a value from the config
remove <any shape>
remove a value from the config
clear
clear the config
path
return the path to the config file
## Variables
| Variable | Type | Description |
| ------------------ | ---------------------- | ------------------------------------------------------------------------- |
| path | table of strings | PATH to use to find binaries |
| env | row | the environment variables to pass to external commands |
| ctrlc_exit | boolean | whether or not to exit Nu after multiple ctrl-c presses |
| table_mode | "light" or other | enable lightweight or normal tables |
| edit_mode | "vi" or "emacs" | changes line editing to "vi" or "emacs" mode |
| key_timeout | integer (milliseconds) | vi: the delay to wait for a longer key sequence after ESC |
| history_size | integer | maximum entries that will be stored in history (100,000 default) |
| completion_type | "circular" or "list" | changes completion type to "circular" (default) or "list" mode |
| complete_from_path | boolean | whether or not to complete names of binaries on PATH (default true) |
| rm_always_trash | boolean | whether or not to always use system trash when no flags are given to `rm` |
| pivot_mode | "auto" or "always" or "never" | "auto" will only pivot single row tables if the output is greater than the terminal width. "always" will always pivot single row tables. "never" will never pivot single row tables. |
| plugin_dirs | table of strings | additional directories to search for plugins during startup |
## Examples
```shell
> config set table_mode "light"
```
A more detailed description on how to use this command to configure Nu shell can be found in the configuration chapter of [Nu Book](https://www.nushell.sh/book/en/configuration.html).

27
docs/commands/cp.md Normal file
View File

@ -0,0 +1,27 @@
# cp
Copy files.
## Usage
```shell
> cp <src> <dst> {flags}
```
## Parameters
* `<src>` the place to copy from
* `<dst>` the place to copy to
## Flags
* -h, --help: Display this help message
* -r, --recursive: copy recursively through subdirectories
## Examples
Copy myfile to dir_b
```shell
> cp myfile dir_b
```
Recursively copy dir_a to dir_b
```shell
> cp -r dir_a dir_b
```

View File

@ -0,0 +1,26 @@
# date format
Format a given date using the given format string.
## Usage
```shell
> date format <format> {flags}
```
## Parameters
* `<format>` strftime format
## Flags
* -h, --help: Display this help message
* -t, --table: print date in a table
## Examples
Format the current date
```shell
> date now | date format '%Y.%m.%d_%H %M %S,%z'
```
Format the current date and print in a table
```shell
> date now | date format -t '%Y-%m-%d_%H:%M:%S %z'
```

View File

@ -0,0 +1,24 @@
# date humanize
Print a 'humanized' format for the date, relative to now.
## Usage
```shell
> date humanize
```
## Flags
* -h, --help: Display this help message
* -t, --table: print date in a table
## Examples
Format the current date
```shell
> date now | date humanize
```
Format the current date and print in a table
```shell
> date now | date humanize -t
```

View File

@ -0,0 +1,22 @@
# date list-timezone
List supported time zones.
## Usage
```shell
> date list-timezone {flags}
```
## Flags
* -h, --help: Display this help message
## Examples
List all supported time zones
```shell
> date list-timezone
```
List all supported European time zones
```shell
> date list-timezone | where timezone =~ Europe
```

11
docs/commands/date-now.md Normal file
View File

@ -0,0 +1,11 @@
# date now
Get the current date.
## Usage
```shell
> date now {flags}
```
## Flags
* -h, --help: Display this help message

View File

@ -0,0 +1,17 @@
# date to-table
Print the date in a structured table.
## Usage
```shell
> date to-table {flags}
```
## Flags
* -h, --help: Display this help message
## Examples
Print the current date in a table
```shell
> date now | date to-table
```

View File

@ -0,0 +1,32 @@
# date to-timezone
Convert a date to a given time zone.
Use 'date list-timezone' to list all supported time zones.
## Usage
```shell
> date to-timezone <time zone> {flags}
```
## Parameters
<time zone> time zone description
## Flags
* -h, --help: Display this help message
## Examples
Get the current date in UTC+05:00
```shell
> date now | date to-timezone +0500
```
Get the current local date
```shell
> date now | date to-timezone local
```
Get the current date in Hawaii
```shell
> date now | date to-timezone US/Hawaii
```

52
docs/commands/date.md Normal file
View File

@ -0,0 +1,52 @@
# date
Use `date` to get the current date and time. Defaults to local timezone but you can get it in UTC too.
## Flags
--utc
Returns the current date and time in UTC
--local
Returns the current date and time in your local timezone
## Examples
```shell
> date
──────────┬────────
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
──────────┴────────
```

67
docs/commands/debug.md Normal file
View File

@ -0,0 +1,67 @@
# debug
`debug` prints a debugging view of the table data. It is useful when you want to get the specific types of the data and while investigating errors.
## Examples
```shell
> ls | first 2 | debug
───┬──────────────────────────────────────────
# │
───┼──────────────────────────────────────────
0(name=".azure"
type="Dir"
size=nothing
modified=2020-02-09T05:31:39.950305440Z((B
│ mdate))
1(name=".cargo"
type="Dir"
size=nothing
modified=2020-01-06T05:45:30.933303081Z((B
│ mdate))
───┴──────────────────────────────────────────
```
```shell
> ls | last 8 | get type | debug
───┬───────────────────────
# │
───┼───────────────────────
0"Dir"
1"Dir"
2"File"
3"Dir"
4"File"
5"Dir"
6"Dir"
7"Dir"
───┴───────────────────────
```
```shell
> open --raw Cargo.toml | size | debug
(lines=139 words=560 chars=4607 bytes=4607)
```
```shell
> du src/ | debug
(path="src"(path)
apparent=705300(bytesize)
physical=1118208(bytesize)
directories=[(path="src/utils"(path) apparent=21203(bytesize) physical=24576(bytesize))
(path="src/data"(path)
apparent=52860(bytesize)
physical=86016(bytesize)
directories=[(path="src/data/config"(path) apparent=2609(bytesize) physical=12288(bytesize))
(path="src/data/base"(path) apparent=12627(bytesize) physical=16384(bytesize))])
(path="src/env"(path) apparent=30257(bytesize) physical=36864(bytesize))
(path="src/plugins"(path) apparent=1358(bytesize) physical=49152(bytesize))
(path="src/commands"(path)
apparent=412617(bytesize)
physical=651264(bytesize)
directories=[(path="src/commands/classified"(path) apparent=37125(bytesize) physical=49152(bytesize))])
(path="src/evaluate"(path) apparent=11475(bytesize) physical=24576(bytesize))
(path="src/format"(path) apparent=15426(bytesize) physical=24576(bytesize))
(path="src/shell"(path) apparent=81093(bytesize) physical=94208(bytesize))])
```

73
docs/commands/def.md Normal file
View File

@ -0,0 +1,73 @@
# def
Use `def` to create a custom command.
## Examples
```shell
> def my_command [] { echo hi nu }
> my_command
hi nu
```
```shell
> def my_command [adjective: string, num: int] { echo $adjective $num meet nu }
> my_command nice 2
nice 2 meet nu
```
```shell
def my_cookie_daemon [
in: path # Specify where the cookie daemon shall look for cookies :p
...rest: path # Other places to consider for cookie supplies
--output (-o): path # Where to store leftovers
--verbose
] {
echo $in $rest | each { eat $it }
...
}
my_cookie_daemon /home/bob /home/alice --output /home/mallory
```
Further (and non trivial) examples can be found in our [nushell scripts repo](https://github.com/nushell/nu_scripts)
## Syntax
The syntax of the def command is as follows.
`def <name> <signature> <block>`
The signature is a list of parameters flags and at maximum one rest argument. You can specify the type of each of them by appending `: <type>`.
Example:
```shell
def cmd [
parameter: string
--flag: int
...rest: path
] { ... }
```
It is possible to comment them by appending `# Comment text`!
Example
```shell
def cmd [
parameter # Parameter comment
--flag: int # Flag comment
...rest: path # Rest comment
] { ... }
```
Flags can have a single character shorthand form. For example `--output` is often abbreviated by `-o`. You can declare a shorthand by writing `(-<shorthand>)` after the flag name.
Example
```shell
def cmd [
--flag(-f): int # Flag comment
] { ... }
```
You can make a parameter optional by adding `?` to its name. Optional parameters do not need to be passed.
(TODO Handling optional parameters in scripts is WIP. Please don't expect it to work seamlessly)
```shell
def cmd [
parameter?: path # Optional parameter
] { ... }
```

37
docs/commands/default.md Normal file
View File

@ -0,0 +1,37 @@
# default
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]
```
## Examples
Let's say we have a table like this:
```shell
> open contacts.json
━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━
# │ name │ email
───┼──────────┼──────────────────
0 │ paul │ paul@example.com
1 │ andres │
2 │ jonathan │
━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━
```
`default` allows us to fill `email` column with a default value:
```shell
> open contacts.json | default email "no-reply@example.com"
━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━
# │ name │ email
───┼──────────┼──────────────────────
0 │ paul │ paul@example.com
1 │ andres │ no-reply@example.com
2 │ jonathan │ no-reply@example.com
━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━
```

11
docs/commands/describe.md Normal file
View File

@ -0,0 +1,11 @@
# describe
Describes the objects in the stream.
## Usage
```shell
> describe {flags}
```
## Flags
* -h, --help: Display this help message

32
docs/commands/do.md Normal file
View File

@ -0,0 +1,32 @@
# do
Runs a block, optionally ignoring errors.
## Usage
```shell
> do <block> ...args {flags}
```
## Parameters
* `<block>` the block to run
* ...args: the parameter(s) for the block
## Flags
* -h, --help: Display this help message
* -i, --ignore-errors: ignore errors as the block runs
## Examples
Run the block
```shell
> do { echo hello }
```
Run the block and ignore errors
```shell
> do -i { thisisnotarealcommand }
```
Run the block with a parameter
```shell
> do { |x| $x + 100 } 55
```

View File

@ -0,0 +1,20 @@
# drop column
Remove the last number of columns. If you want to remove columns by name, try 'reject'.
## Usage
```shell
> drop column (columns) {flags}
```
## Parameters
* `(columns)` starting from the end, the number of columns to remove
## Flags
* -h, --help: Display this help message
## Examples
Remove the last column of a table
```shell
> echo [[lib, extension]; [nu-lib, rs] [nu-core, rb]] | drop column
```

28
docs/commands/drop.md Normal file
View File

@ -0,0 +1,28 @@
# drop
Remove the last number of rows or columns.
## Usage
```shell
> drop (rows) <subcommand> {flags}
```
## Subcommands
* drop column - Remove the last number of columns. If you want to remove columns by name, try 'reject'.
## Parameters
* `(rows)` starting from the back, the number of rows to remove
## Flags
* -h, --help: Display this help message
## Examples
Remove the last item of a list/table
```shell
> echo [1 2 3] | drop
```
Remove the last 2 items of a list/table
```shell
> echo [1 2 3] | drop 2
```

36
docs/commands/du.md Normal file
View File

@ -0,0 +1,36 @@
# du
`du` stands for disk usage. It will give you the physical and apparent size of files and folders
## Examples
```shell
> du src/commands
─────────────┬────────────────────────────
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 │ 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

@ -0,0 +1,21 @@
# each group
Runs a block on groups of `group_size` rows of a table at a time.
## Usage
```shell
> each group <group_size> <block> {flags}
```
## Parameters
* `<group_size>` the size of each group
* `<block>` the block to run on each group
## Flags
* -h, --help: Display this help message
## Examples
Echo the sum of each pair
```shell
> echo [1 2 3 4] | each group 2 { echo $it | math sum }
```

View File

@ -0,0 +1,22 @@
# each window
Runs a block on sliding windows of `window_size` rows of a table at a time.
## Usage
```shell
> each window <window_size> <block> {flags}
```
## Parameters
* `<window_size>` the size of each window
* `<block>` the block to run on each group
## Flags
* -h, --help: Display this help message
* -s, --stride <integer>: the number of rows to slide over between windows
## Examples
Echo the sum of each window
```shell
> echo [1 2 3 4] | each window 2 { echo $it | math sum }
```

40
docs/commands/each.md Normal file
View File

@ -0,0 +1,40 @@
# each
Run a block on each row of the table.
## Usage
```shell
> each <block> <subcommand> {flags}
```
## Subcommands
* each group - Runs a block on groups of `group_size` rows of a table at a time.
* each window - Runs a block on sliding windows of `window_size` rows of a table at a time.
## Parameters
* `<block>` the block to run on each row
## Flags
* -h, --help: Display this help message
* -n, --numbered: returned a numbered item ($it.index and $it.item)
## Examples
Echo the sum of each row
```shell
> echo [[1 2] [3 4]] | each { echo $it | math sum }
```
Echo the square of each integer
```shell
> echo [1 2 3] | each { echo ($it * $it) }
```
Number each item and echo a message
```shell
> echo ['bob' 'fred'] | each --numbered { echo $"($it.index) is ($it.item)" }
```
Name the block variable that each uses
```shell
> [1, 2, 3] | each {|x| $x + 100}
```

20
docs/commands/echo.md Normal file
View File

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

76
docs/commands/empty.md Normal file
View File

@ -0,0 +1,76 @@
# empty?
Check for empty values. Pass the column names to check emptiness. Optionally pass a block as the last parameter if setting contents to empty columns is wanted.
## Examples
Check if a value is empty
```shell
> echo '' | empty?
true
```
Given the following meals
```shell
> echo [[meal size]; [arepa small] [taco '']]
═══╦═══════╦═══════
# ║ meal ║ size
═══╬═══════╬═══════
0 ║ arepa ║ small
1 ║ taco ║
═══╩═══════╩═══════
```
Show the empty contents
```shell
> echo [[meal size]; [arepa small] [taco '']] | empty? meal size
═══╦═══════╦═══════
# ║ meal ║ size
═══╬═══════╬═══════
0falsefalse
1falsetrue
═══╩═══════╩═══════
```
Let's assume we have a report of totals per day. For simplicity we show just for three days `2020/04/16`, `2020/07/10`, and `2020/11/16`. Like so
```shell
> echo [[2020/04/16 2020/07/10 2020/11/16]; ['' 27 37]]
═══╦════════════╦════════════╦════════════
# ║ 2020/04/16 ║ 2020/07/10 ║ 2020/11/16
═══╬════════════╬════════════╬════════════
0 ║ ║ 2737
═══╩════════════╩════════════╩════════════
```
In the future, the report now has many totals logged per day. In this example, we have 1 total for the day `2020/07/10` and `2020/11/16` like so
```shell
> echo [[2020/04/16 2020/07/10 2020/11/16]; ['' [27] [37]]]
═══╦════════════╦════════════════╦════════════════
# ║ 2020/04/16 ║ 2020/07/10 ║ 2020/11/16
═══╬════════════╬════════════════╬════════════════
0 ║ ║ [table 1 rows][table 1 rows]
═══╩════════════╩════════════════╩════════════════
```
We want to add two totals (numbers `33` and `37`) for the day `2020/04/16`
Set a table with two numbers for the empty column
```shell
> echo [[2020/04/16 2020/07/10 2020/11/16]; ['' [27] [37]]] | empty? 2020/04/16 { [33 37] }
═══╦════════════════╦════════════════╦════════════════
# ║ 2020/04/16 ║ 2020/07/10 ║ 2020/11/16
═══╬════════════════╬════════════════╬════════════════
0[table 2 rows][table 1 rows][table 1 rows]
═══╩════════════════╩════════════════╩════════════════
```
Checking all the numbers
```shell
> echo [[2020/04/16 2020/07/10 2020/11/16]; ['' [27] [37]]] | empty? 2020/04/16 { [33 37] } | pivot _ totals | get totals
═══╦════
033
137
227
337
═══╩════
```

58
docs/commands/enter.md Normal file
View File

@ -0,0 +1,58 @@
# enter
This command creates a new shell and begin at this path.
## Examples
```shell
/home/foobar> cat user.json
{
"Name": "Peter",
"Age": 30,
"Telephone": 88204828,
"Country": "Singapore"
}
/home/foobar> enter user.json
/> ls
━━━━━━━┯━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━
Name │ Age │ Telephone │ Country
───────┼─────┼───────────┼───────────
Peter │ 3088204828 │ Singapore
━━━━━━━┷━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━
/> exit
/home/foobar>
```
It also provides the ability to work with multiple directories at the same time. This command will allow you to create a new "shell" and enter it at the specified path. You can toggle between this new shell and the original shell with the `p` (for previous) and `n` (for next), allowing you to navigate around a ring buffer of shells. Once you're done with a shell, you can `exit` it and remove it from the ring buffer.
```shell
/> enter /tmp
/tmp> enter /usr
/usr> enter /bin
/bin> enter /opt
/opt> p
/bin> p
/usr> p
/tmp> p
/> n
/tmp>
```
## Note
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
/private/tmp> enter foo.json
/> shells
───┬────────┬─────────────────────────┬──────────────
# │ active │ name │ path
───┼────────┼─────────────────────────┼──────────────
0 │ │ filesystem │ /private/tmp
1 │ │ {/private/tmp/foo.json} │ /
2 │ │ {/private/tmp/foo.json} │ /
3 │ X │ {/private/tmp/foo.json} │ /
───┴────────┴─────────────────────────┴──────────────
/>
```

45
docs/commands/every.md Normal file
View File

@ -0,0 +1,45 @@
# every
Selects every n-th row of a table, starting from the first one. With the `--skip` flag, every n-th row will be skipped, inverting the original functionality.
Syntax: `> [input-command] | every <stride> {flags}`
## Flags
* `--skip`, `-s`: Skip the rows that would be returned, instead of selecting them
## Examples
```shell
> open contacts.csv
───┬─────────┬──────┬─────────────────
# │ first │ last │ email
───┼─────────┼──────┼─────────────────
0 │ John │ Doe │ doe.1@email.com
1 │ Jane │ Doe │ doe.2@email.com
2 │ Chris │ Doe │ doe.3@email.com
3 │ Francis │ Doe │ doe.4@email.com
4 │ Stella │ Doe │ doe.5@email.com
───┴─────────┴──────┴─────────────────
```
```shell
> open contacts.csv | every 2
───┬─────────┬──────┬─────────────────
# │ first │ last │ email
───┼─────────┼──────┼─────────────────
0 │ John │ Doe │ doe.1@email.com
2 │ Chris │ Doe │ doe.3@email.com
4 │ Stella │ Doe │ doe.5@email.com
───┴─────────┴──────┴─────────────────
```
```shell
> open contacts.csv | every 2 --skip
───┬─────────┬──────┬─────────────────
# │ first │ last │ email
───┼─────────┼──────┼─────────────────
1 │ Jane │ Doe │ doe.2@email.com
3 │ Francis │ Doe │ doe.4@email.com
───┴─────────┴──────┴─────────────────
```

26
docs/commands/exec.md Normal file
View File

@ -0,0 +1,26 @@
# exec
Execute command.
## Usage
```shell
> exec <command> ...args {flags}
```
## Parameters
* `<command>` the command to execute
* ...args: any additional arguments for command
## Flags
* -h, --help: Display this help message
## Examples
Execute 'ps aux'
```shell
> exec ps aux
```
Execute 'nautilus'
```shell
> exec nautilus
```

30
docs/commands/exit.md Normal file
View File

@ -0,0 +1,30 @@
# exit
Exits the nu shell. If you have multiple nu shells, use `exit --now` to exit all of them.
## Examples
```shell
> exit
```
```shell
> shells
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path
───┼───┼────────────┼─────────────────────────────────────
0 │ │ filesystem │ /home/jonathanturner/Source/nushell
1 │ │ filesystem │ /home
2 │ X │ filesystem │ /usr
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
> exit
> shells
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path
───┼───┼────────────┼─────────────────────────────────────
0 │ │ filesystem │ /home/jonathanturner/Source/nushell
1 │ X │ filesystem │ /home
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
> exit --now
exits both the shells
```

32
docs/commands/fetch.md Normal file
View File

@ -0,0 +1,32 @@
# fetch
This command loads from a URL into a cell, convert it to table if possible (avoid by appending `--raw` flag)
## Examples
```shell
> fetch http://headers.jsontest.com
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━
X-Cloud-Trace-Context │ Accept │ Host │ Content-Length │ user-agent
───────────────────────────────────────────────────────┼────────┼──────────────────────┼────────────────┼─────────────────────────
aeee1a8abf08820f6fe19d114dc3bb87/16772233176633589121 │ */* │ headers.jsontest.com │ 0 │ curl/7.54.0 isahc/0.7.1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━
> fetch http://headers.jsontest.com --raw
{
"X-Cloud-Trace-Context": "aeee1a8abf08820f6fe19d114dc3bb87/16772233176633589121",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36",
"Host": "headers.jsontest.com",
"Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8"
}
```
```shell
> fetch https://www.jonathanturner.org/feed.xml
━━━━━━━━━━━━━━━━
rss
────────────────
[table: 1 row]
━━━━━━━━━━━━━━━━
```

31
docs/commands/first.md Normal file
View File

@ -0,0 +1,31 @@
# first
Use `first` to retrieve the first "n" rows of a table. `first` has a required amount parameter that indicates how many rows you would like returned. If more than one row is returned, an index column will be included showing the row number.
## Examples
```shell
> ps | first 1
─────────┬──────────────────
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 │ 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
───┴───────┴──────────────────┴─────────┴──────────┴─────────┴─────────
```

30
docs/commands/flatten.md Normal file
View File

@ -0,0 +1,30 @@
# flatten
Flatten the table.
## Usage
```shell
> flatten ...args {flags}
```
## Parameters
* ...args: optionally flatten data by column
## Flags
* -h, --help: Display this help message
## Examples
* flatten a table
```shell
> echo [[N, u, s, h, e, l, l]] | flatten | first
```
* flatten a column having a nested table
```shell
> echo [[origin, people]; [Ecuador, (echo [[name, meal]; ['Andres', 'arepa']])]] | flatten | get meal
```
restrict the flattening by passing column names
```shell
> echo [[origin, crate, versions]; [World, (echo [[name]; ['nu-cli']]), ['0.21', '0.22']]] | flatten versions | last | get versions
```

34
docs/commands/for.md Normal file
View File

@ -0,0 +1,34 @@
# for
Run a block on each row of the table.
## Usage
```shell
> for <var> <in> <value> <block> {flags}
```
## Parameters
* `<var>` the name of the variable
* `<in>` the word 'in'
* `<value>` the value we want to iterate
* `<block>` the block to run on each item
## Flags
* -h, --help: Display this help message
* -n, --numbered: returned a numbered item ($it.index and $it.item)
## Examples
Echo the square of each integer
```shell
> for x in [1 2 3] { $x * $x }
```
Work with elements of a range
```shell
> for $x in 1..3 { $x }
```
Number each item and echo a message
```shell
> for $it in ['bob' 'fred'] --numbered { $"($it.index) is ($it.item)" }
```

View File

@ -0,0 +1,26 @@
# format filesize
Converts a column of filesizes to some specified format
## Usage
```shell
> format filesize <field> <format value> {flags}
```
## Parameters
* `<field>` the name of the column to update
<format value> the format into which convert the filesizes
## Flags
* -h, --help: Display this help message
## Examples
Convert the size row to KB
```shell
> ls | format filesize size KB
```
Convert the apparent row to B
```shell
> du | format filesize apparent B
```

37
docs/commands/format.md Normal file
View File

@ -0,0 +1,37 @@
# format
Format columns into a string using a simple pattern
Syntax: `format <pattern>`
## Parameters
* `<pattern>`: the pattern to match
## Example
Let's say we have a table like this:
```shell
> open pets.csv
━━━┯━━━━━━━━━━━┯━━━━━━━━┯━━━━━
# │ animal │ name │ age
───┼───────────┼────────┼─────
0 │ cat │ Tom │ 7
1 │ dog │ Alfred │ 10
2 │ chameleon │ Linda │ 1
━━━┷━━━━━━━━━━━┷━━━━━━━━┷━━━━━
```
`format` allows us to convert table data into a string by following a formatting pattern. To print the value of a column we have to put the column name in curly brackets:
```shell
> open pets.csv | format "{name} is a {age} year old {animal}"
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │
───┼─────────────────────────────────
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

@ -0,0 +1,11 @@
# from bson
Convert from .bson binary into table
## Usage
```shell
> from bson {flags}
```
## Flags
* -h, --help: Display this help message

116
docs/commands/from-csv.md Normal file
View File

@ -0,0 +1,116 @@
# from csv
Converts csv data into table. Use this when nushell cannot determine the input file extension.
## Example
Let's say we have the following file:
```shell
> cat pets.txt
animal, name, age
cat, Tom, 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:
```shell
> open pets.txt
animal, name, age
cat, Tom, 7
dog, Alfred, 10
chameleon, Linda, 1
```
To get a table from `pets.txt` we need to use the `from csv` command:
```shell
> open pets.txt | from csv
━━━┯━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━
# │ animal │ name │ age
───┼───────────┼─────────┼──────
0 │ cat │ Tom │ 7
1 │ dog │ Alfred │ 10
2 │ chameleon │ Linda │ 1
━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━
```
To ignore the csv headers use `--headerless`:
```shell
━━━┯━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━
# │ Column1 │ Column2 │ Column3
───┼───────────┼─────────┼─────────
0 │ dog │ Alfred │ 10
1 │ chameleon │ Linda │ 1
━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━
```
To split on a character other than ',' use `--separator`:
```shell
> open pets.txt
animal; name; age
cat; Tom; 7
dog; Alfred; 10
chameleon; Linda; 1
```
```shell
> open pets.txt | from csv --separator ';'
━━━┯━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━
# │ animal │ name │ age
───┼───────────┼─────────┼──────
0 │ cat │ Tom │ 7
1 │ dog │ Alfred │ 10
2 │ chameleon │ Linda │ 1
━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━
```
To use this command to open a csv with separators other than a comma, use the `--raw` switch of `open` to open the csv, otherwise the csv will enter `from csv` as a table split on commas rather than raw text.
```shell
> mv pets.txt pets.csv
> open pets.csv | from csv --separator ';'
error: Expected a string from pipeline
- shell:1:16
1 | open pets.csv | from csv --separator ';'
| ^^^^^^^^ requires string input
- shell:1:0
1 | open pets.csv | from csv --separator ';'
| value originates from here
> open pets.csv --raw | from csv --separator ';'
━━━┯━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━
# │ animal │ name │ age
───┼───────────┼─────────┼──────
0 │ cat │ Tom │ 7
1 │ dog │ Alfred │ 10
2 │ chameleon │ Linda │ 1
━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━
```
The string '\t' can be used to separate on tabs. Note that this is the same as using the from tsv command.
Newlines '\n' are not acceptable separators.
Note that separators are currently provided as strings and need to be wrapped in quotes.
```shell
> open pets.csv --raw | from csv --separator ;
- shell:1:43
1 | open pets.csv --raw | from csv --separator ;
| ^
```
It is also considered an error to use a separator greater than one char:
```shell
> open pets.txt | from csv --separator '123'
error: Expected a single separator char from --separator
- shell:1:37
1 | open pets.txt | from csv --separator '123'
| ^^^^^ requires a single character string input
```

12
docs/commands/from-eml.md Normal file
View File

@ -0,0 +1,12 @@
# from eml
Parse text as .eml and create table.
## Usage
```shell
> from eml {flags}
```
## Flags
* -h, --help: Display this help message
* -b, --preview-body <integer>: How many bytes of the body to preview

40
docs/commands/from-ics.md Normal file
View File

@ -0,0 +1,40 @@
# from ics
Parse text as `.ics` and create table.
Syntax: `from ics`
## Examples
Suppose calendar.txt is a text file that is formatted like a `.ics` (iCal) file:
```shell
> open calendar.txt
BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20171007T200000Z
DTEND:20171007T233000Z
DTSTAMP:20200319T182138Z
SUMMARY:Basketball Game
UID:4l80f6dcovnriq38g57g07btid@google.com
...
```
Pass the output of the `open` command to `from ics` to get a correctly formatted table:
```shell
> open calendar.txt | from ics
───┬────────────────┬──────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────
# │ properties │ events │ alarms │ to-Dos │ journals │ free-busys │ timezones
───┼────────────────┼──────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────
0[table 0 rows][table 1 row][table 0 rows][table 0 rows][table 0 rows][table 0 rows][table 0 rows]
───┴────────────────┴──────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────
```
```shell
> open calendar.txt | from ics | get events | get properties | where name == "SUMMARY"
─────┬─────────┬───────────────────────────────────────┬────────
# │ name │ value │ params
─────┼─────────┼───────────────────────────────────────┼────────
0 │ SUMMARY │ Basketball Game │
```

27
docs/commands/from-ini.md Normal file
View File

@ -0,0 +1,27 @@
# from ini
Converts ini data into table. Use this when nushell cannot determine the input file extension.
## Example
Let's say we have the following `.txt` file:
```shell
> open sample.txt
[SectionOne]
key = value
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:
```shell
> open sample.txt | from ini | get SectionOne
━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━
key │ integer │ string1
───────┼─────────┼──────────
value │ 1234'Case 1'
━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━
```

View File

@ -0,0 +1,32 @@
# from json
Parse text as `.json` and create table. Use this when nushell cannot determine the input file extension.
Syntax: `from json {flags}`
## Flags
--objects
treat each line as a separate value
## Examples
```shell
> open command_from-json
[
{
title: "from json",
type: "command",
flags: true
}
]
```
```shell
> open command_from-json | from json
━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━
title │ type │ flags
───────────┼─────────┼───────
from json │ commandtrue
━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━
```

39
docs/commands/from-ods.md Normal file
View File

@ -0,0 +1,39 @@
# from ods
Parses OpenDocument Spreadsheet binary data into a table. `open` calls `from ods` automatically when the file extension is `ods`. Use this command when `open` is unable to guess the file type from the extension.
## Flags
* -h, --help: Display this help message
* -s, --sheets \[\<sheet_name_1> \<sheet_name_2> ... \<sheet_name_N>]: Only convert specified sheets. Non-existing sheets are skipped.
## Examples
```sh
> open abc.ods
─────────────────
Sheet1
─────────────────
[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
0010: 39 8a 2e 00 00 00 2e 00 00 00 08 00 00 00 6d 69 9.............mi
0020: 6d 65 74 79 70 65 61 70 70 6c 69 63 61 74 69 6f metypeapplicatio
...
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
─────────────────
[table 26 rows]
─────────────────
```

View File

@ -0,0 +1,11 @@
# from sqlite
Convert from sqlite binary into table
## Usage
```shell
> from sqlite {flags}
```
## Flags
* -h, --help: Display this help message
* -t, --tables \[\<table_name_1> \<table_name_2> ... \<table_name_N>]: Only convert specified tables

14
docs/commands/from-ssv.md Normal file
View File

@ -0,0 +1,14 @@
# from ssv
Parse text as space-separated values and create a table. The default minimum number of spaces counted as a separator is 2.
## Usage
```shell
> from ssv {flags}
```
## Flags
* -h, --help: Display this help message
* -n, --noheaders: don't treat the first row as column names
* -a, --aligned-columns: assume columns are aligned
* -m, --minimum-spaces <integer>: the minimum spaces to separate columns

View File

@ -0,0 +1,23 @@
# 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:
```shell
> open Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing. [[package]] name = "adler32" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index"
...
```
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
─────────┬──────────────────
package │ [table 459 rows]
─────────┴──────────────────
```

52
docs/commands/from-tsv.md Normal file
View File

@ -0,0 +1,52 @@
# from tsv
Parse text as `.tsv` and create table.
Syntax: `from tsv {flags}`
## Flags
--headerless
don't treat the first row as column names
## Examples
Let's say we have the following file which is formatted like a `tsv` file:
```shell
> open elements.txt
Symbol Element
H Hydrogen
He Helium
Li Lithium
Be Beryllium
```
If we pass the output of the `open` command to `from tsv` we get a correct formatted table:
```shell
> open elements.txt | from tsv
━━━┯━━━━━━━━┯━━━━━━━━━━━
# │ Symbol │ Element
───┼────────┼───────────
0 │ H │ Hydrogen
1 │ He │ Helium
2 │ Li │ Lithium
3 │ Be │ Beryllium
━━━┷━━━━━━━━┷━━━━━━━━━━━
```
Using the `--headerless` flag has the following output:
```shell
> open elements.txt | from tsv --headerless
━━━━┯━━━━━━━━━┯━━━━━━━━━━━
# │ Column1 │ Column2
────┼─────────┼───────────
0 │ Symbol │ Element
1 │ H │ Hydrogen
2 │ He │ Helium
3 │ Li │ Lithium
4 │ Be │ Beryllium
━━━━┷━━━━━━━━━┷━━━━━━━━━━━
```

15
docs/commands/from-url.md Normal file
View File

@ -0,0 +1,15 @@
# from url
Parse [url-encoded string](https://url.spec.whatwg.org/#application/x-www-form-urlencoded) as a table.
## Example
```shell
> echo 'bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter' | from url
────────┬──────────
bread │ baguette
cheese │ comté
meat │ ham
fat │ butter
────────┴──────────
```

37
docs/commands/from-vcf.md Normal file
View File

@ -0,0 +1,37 @@
# from vcf
Parse text as `.vcf` and create table.
Syntax: `from vcf`
## Examples
Suppose contacts.txt is a text file that is formatted like a `.vcf` (vCard) file:
```shell
> open contacts.txt
BEGIN:VCARD
VERSION:3.0
FN:John Doe
N:Doe;John;;;
EMAIL;TYPE=INTERNET:john.doe99@gmail.com
...
```
Pass the output of the `open` command to `from vcf` to get a correctly formatted table:
```shell
> open contacts.txt | from vcf
─────┬─────────────────
# │ properties
─────┼─────────────────
0[table 8 rows]
```
```shell
> open contacts.txt | from vcf | get properties | where $it.name == "FN" | select value
─────┬──────────────────────
# │
─────┼──────────────────────
0 │ John Doe
```

View File

@ -0,0 +1,33 @@
# from xlsx
Parses MS Excel binary data into a table. `open` calls `from xlsx` automatically when the file extension is `xlsx`. Use this command when `open` is unable to guess the file type from the extension.
## Flags
* -h, --help: Display this help message
* -s, --sheets \[\<sheet_name_1> \<sheet_name_2> ... \<sheet_name_N>]: Only convert specified sheets. Non-existing sheets are skipped.
## Examples
```shell
> open abc.xlsx
─────────────────
Sheet1
─────────────────
[table 26 rows]
─────────────────
> open abc.xlsx --raw
Length: 6344 (0x18c8) bytes
0000: 50 4b 03 04 14 00 00 00 08 00 00 00 00 00 d5 5f PK............._
0010: a7 48 68 01 00 00 23 05 00 00 13 00 00 00 5b 43 .Hh...#.......[C
0020: 6f 6e 74 65 6e 74 5f 54 79 70 65 73 5d 2e 78 6d ontent_Types].xm
...
18a0: 6b 73 68 65 65 74 73 2f 73 68 65 65 74 31 2e 78 ksheets/sheet1.x
18b0: 6d 6c 50 4b 05 06 00 00 00 00 0a 00 0a 00 7f 02 mlPK............
18c0: 00 00 33 16 00 00 00 00 ..3.....
> open abc.xlsx --raw | from xlsx
─────────────────
Sheet1
─────────────────
[table 26 rows]
─────────────────
```

34
docs/commands/from-xml.md Normal file
View File

@ -0,0 +1,34 @@
# from xml
Parse text as `.xml` and create table. Use this when nushell cannot determine the input file extension.
Syntax: `from xml`
## Examples
Let's say we've got a file in `xml` format but the file extension is different so Nu can't auto-format it:
```shell
> open world.txt
<?xml version="1.0" encoding="utf-8"?>
<world>
<continent>Africa</continent>
<continent>Antarctica</continent>
<continent>Asia</continent>
<continent>Australia</continent>
<continent>Europe</continent>
<continent>North America</continent>
<continent>South America</continent>
</world>
```
We can use `from xml` to read the input like a `xml` file:
```shell
> open world.txt | from xml
━━━━━━━━━━━━━━━━
world
────────────────
[table 7 rows]
━━━━━━━━━━━━━━━━
```

View File

@ -0,0 +1,23 @@
# from yaml
Parse text as `.yaml/.yml` and create table. Use this when nushell cannot determine the input file extension.
Syntax: `from yaml`
## Examples
```shell
> open command_from-yaml
title: from-yaml
type: command
flags: false
```
```shell
> open command_from-yaml | from yaml
━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━
title │ type │ flags
───────────┼─────────┼───────
from-yaml │ command │ No
━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━
```

11
docs/commands/from-yml.md Normal file
View File

@ -0,0 +1,11 @@
# from yml
Parse text as .yaml/.yml and create table.
## Usage
```shell
> from yml {flags}
```
## Flags
* -h, --help: Display this help message

61
docs/commands/from.md Normal file
View File

@ -0,0 +1,61 @@
# from csv
Converts content (string or binary) into a table. The source format is specified as a subcommand, like `from csv` or `from json`.
Use this when nushell cannot determine the input file extension.
## Available Subcommands
* from bson
* [from csv](from-csv.md)
* from eml
* [from ics](from-ics.md)
* [from ini](from-ini.md)
* [from json](from-json.md)
* [from ods](from-ods.md)
* from sqlite
* from ssv
* [from toml](from-toml.md)
* [from tsv](from-tsv.md)
* [from url](from-url.md)
* [from vcf](from-vcf.md)
* [from xlsx](from-xlsx.md)
* [from xml](from-xml.md)
* [from yaml](from-yaml.md)
*Subcommands without links are currently missing their documentation.*
## Example for `from csv`
Let's say we have the following file:
```shell
> cat pets.txt
animal, name, age
cat, Tom, 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:
```shell
> open pets.txt
animal, name, age
cat, Tom, 7
dog, Alfred, 10
chameleon, Linda, 1
```
To get a table from `pets.txt` we need to use the `from csv` command:
```shell
> open pets.txt | from csv
━━━┯━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━
# │ animal │ name │ age
───┼───────────┼─────────┼──────
0 │ cat │ Tom │ 7
1 │ dog │ Alfred │ 10
2 │ chameleon │ Linda │ 1
━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━
```

63
docs/commands/get.md Normal file
View File

@ -0,0 +1,63 @@
# get
Open given cells as text.
Syntax: `get ...args`
## Parameters
* `args`: optionally return additional data by path
## Examples
If we run `sys` we receive a table which contains tables itself:
```shell
> sys
─────────┬─────────────────────────────────────────
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 │ 16
current ghz │ 2.4000
min ghz │ 2.4000
max ghz │ 2.4000
─────────────┴────────
```
```shell
> sys | get battery
───────────────┬──────────
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
───┼───────┼─────────────┼─────────┼─────────
016 │ 2.4000 │ 2.4000 │ 2.4000
───┴───────┴─────────────┴─────────┴─────────
───┬────────┬──────────┬────────┬───────────────
# │ vendor │ model │ cycles │ mins to empty
───┼────────┼──────────┼────────┼───────────────
1 │ DSY │ bq40z651 │ 43 │ 70.0000
───┴────────┴──────────┴────────┴───────────────
```

View File

@ -0,0 +1,21 @@
# group-by date
creates a table grouped by date.
## Usage
```shell
> group-by date (column_name) {flags}
```
## Parameters
* `(column_name)` the name of the column to group by
## Flags
* -h, --help: Display this help message
* -f, --format <string>: Specify date and time formatting
## Examples
Group files by type
```shell
> ls | group-by date --format '%d/%m/%Y'
```

72
docs/commands/group-by.md Normal file
View File

@ -0,0 +1,72 @@
# group-by
This command creates a new table with the data from the table rows grouped by the column given.
## Examples
Let's say we have this table of all countries in the world sorted by their population:
```shell
> open countries_by_population.json | from json | first 10
━━━┯━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━
# │ rank │ country or area │ UN continental region │ UN statistical region │ population 2018 │ population 2019 │ change
───┼──────┼─────────────────┼───────────────────────┼───────────────────────┼─────────────────┼─────────────────┼────────
01 │ China │ Asia │ Eastern Asia │ 1,427,647,786 │ 1,433,783,686 │ +0.4%
12 │ India │ Asia │ Southern Asia │ 1,352,642,280 │ 1,366,417,754 │ +1.0%
23 │ United States │ Americas │ Northern America │ 327,096,265 │ 329,064,917 │ +0.6%
34 │ Indonesia │ Asia │ South-eastern Asia │ 267,670,543 │ 270,625,568 │ +1.1%
45 │ Pakistan │ Asia │ Southern Asia │ 212,228,286 │ 216,565,318 │ +2.0%
56 │ Brazil │ Americas │ South America │ 209,469,323 │ 211,049,527 │ +0.8%
67 │ Nigeria │ Africa │ Western Africa │ 195,874,683 │ 200,963,599 │ +2.6%
78 │ Bangladesh │ Asia │ Southern Asia │ 161,376,708 │ 163,046,161 │ +1.0%
89 │ Russia │ Europe │ Eastern Europe │ 145,734,038 │ 145,872,256 │ +0.1%
910 │ Mexico │ Americas │ Central America │ 126,190,788 │ 127,575,529 │ +1.1%
━━━┷━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━
```
Here we have listed only the first 10 lines. In total this table has got 233 rows which is to big to get information easily out of it.
We can use the `group-by` command on 'UN statistical region' to create a table per continental region.
```shell
> open countries_by_population.json | from json | group-by "UN continental region"
━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━
Asia │ Americas │ Africa │ Europe │ Oceania
──────────────────┼──────────────────┼──────────────────┼──────────────────┼──────────────────
[table: 51 rows][table: 53 rows][table: 58 rows][table: 48 rows][table: 23 rows]
━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━
```
Now we can already get some information like "which continental regions are there" and "how many countries are in each region".
If we want to see only the countries in the continental region of Oceania we can type:
```shell
> open countries_by_population.json | from json | group-by "UN continental region" | get Oceania
━━━━┯━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━
# │ rank │ country or area │ UN continental region │ UN statistical region │ population 2018 │ population 2019 │ change
────┼──────┼────────────────────────────────┼───────────────────────┼───────────────────────────┼─────────────────┼─────────────────┼────────
055 │ Australia │ Oceania │ Australia and New Zealand │ 24,898,152 │ 25,203,198 │ +1.2%
198 │ Papua New Guinea │ Oceania │ Melanesia │ 8,606,323 │ 8,776,109 │ +2.0%
2125 │ New Zealand │ Oceania │ Australia and New Zealand │ 4,743,131 │ 4,783,063 │ +0.8%
3161 │ Fiji │ Oceania │ Melanesia │ 883,483 │ 889,953 │ +0.7%
4166 │ Solomon Islands │ Oceania │ Melanesia │ 652,857 │ 669,823 │ +2.6%
5181 │ Vanuatu │ Oceania │ Melanesia │ 292,680 │ 299,882 │ +2.5%
6183 │ New Caledonia │ Oceania │ Melanesia │ 279,993 │ 282,750 │ +1.0%
7185 │ French Polynesia │ Oceania │ Polynesia │ 277,679 │ 279,287 │ +0.6%
8188 │ Samoa │ Oceania │ Polynesia │ 196,129 │ 197,097 │ +0.5%
9191 │ Guam │ Oceania │ Micronesia │ 165,768 │ 167,294 │ +0.9%
10193 │ Kiribati │ Oceania │ Micronesia │ 115,847 │ 117,606 │ +1.5%
11194 │ Federated States of Micronesia │ Oceania │ Micronesia │ 112,640 │ 113,815 │ +1.0%
12196 │ Tonga │ Oceania │ Polynesia │ 110,589 │ 110,940 │ +0.3%
13207 │ Marshall Islands │ Oceania │ Micronesia │ 58,413 │ 58,791 │ +0.6%
14209 │ Northern Mariana Islands │ Oceania │ Micronesia │ 56,882 │ 56,188 │ 1.2%
15210 │ American Samoa │ Oceania │ Polynesia │ 55,465 │ 55,312 │ 0.3%
16221 │ Palau │ Oceania │ Micronesia │ 17,907 │ 18,008 │ +0.6%
17222 │ Cook Islands │ Oceania │ Polynesia │ 17,518 │ 17,548 │ +0.2%
18224 │ Tuvalu │ Oceania │ Polynesia │ 11,508 │ 11,646 │ +1.2%
19225 │ Wallis and Futuna │ Oceania │ Polynesia │ 11,661 │ 11,432 │ 2.0%
20226 │ Nauru │ Oceania │ Micronesia │ 10,670 │ 10,756 │ +0.8%
21231 │ Niue │ Oceania │ Polynesia │ 1,620 │ 1,615 │ 0.3%
22232 │ Tokelau │ Oceania │ Polynesia │ 1,319 │ 1,340 │ +1.6%
━━━━┷━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━┷━━━━━━━━
```

View File

@ -0,0 +1,34 @@
# hash base64
base64 encode or decode a value
## Usage
```shell
> hash base64 ...args {flags}
```
## Parameters
* ...args: optionally base64 encode / decode data by column paths
## Flags
* -h, --help: Display this help message
* -c, --character_set <string>: specify the character rules for encoding the input.
Valid values are 'standard', 'standard-no-padding', 'url-safe', 'url-safe-no-padding','binhex', 'bcrypt', 'crypt'
* -e, --encode: encode the input as base64. This is the default behavior if not specified.
* -d, --decode: decode the input from base64
## Examples
Base64 encode a string with default settings
```shell
> echo 'username:password' | hash base64
```
Base64 encode a string with the binhex character set
```shell
> echo 'username:password' | hash base64 --character_set binhex --encode
```
Base64 decode a value
```shell
> echo 'dXNlcm5hbWU6cGFzc3dvcmQ=' | hash base64 --decode
```

25
docs/commands/hash-md5.md Normal file
View File

@ -0,0 +1,25 @@
# hash md5
md5 encode a value
## Usage
```shell
> hash md5 ...args {flags}
```
## Parameters
* ...args: optionally md5 encode data by column paths
## Flags
* -h, --help: Display this help message
## Examples
md5 encode a string
```shell
> echo 'abcdefghijklmnopqrstuvwxyz' | hash md5
```
md5 encode a file
```shell
> open ./nu_0_24_1_windows.zip | hash md5
```

18
docs/commands/hash.md Normal file
View File

@ -0,0 +1,18 @@
# hash
Apply hash function.
## Usage
```shell
> hash ...args <subcommand> {flags}
```
## Subcommands
* hash base64 - base64 encode or decode a value
* hash md5 - md5 encode a value
## Parameters
* ...args: optionally convert by column paths
## Flags
* -h, --help: Display this help message

25
docs/commands/headers.md Normal file
View File

@ -0,0 +1,25 @@
# headers
Use `headers` to turn the first row of a table into meaningful column names.
As demonstrated in the following example, it's particularly handy when working with spreadsheets.
## Examples
```shell
> 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
```
```shell
> open sample_data.ods | get SalesOrders | headers
────┬────────────┬─────────┬──────────┬─────────┬─────────┬───────────┬───────────
# │ OrderDate │ Region │ Rep │ Item │ Units │ Unit Cost │ Total
────┼────────────┼─────────┼──────────┼─────────┼─────────┼───────────┼───────────
0 │ 2018-01-06 │ East │ Jones │ Pencil │ 95.0000 │ 1.9900 │ 189.0500
1 │ 2018-01-23 │ Central │ Kivell │ Binder │ 50.0000 │ 19.9900 │ 999.4999
```

78
docs/commands/help.md Normal file
View File

@ -0,0 +1,78 @@
# help
Use `help` for more information on a command.
Use `help commands` to list all available commands.
Use `help <command name>` to display help about a particular command.
## Examples
```shell
> help
Welcome to Nushell.
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
────┼──────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
0alias │ Define 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 │ cal │ Display a calendar.
5 │ calc │ Parse a math expression into a number
...
83 │ where │ Filter table to match the condition.
84 │ which │ 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
> help cd
Change to a new path.
Usage:
> 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

@ -0,0 +1,92 @@
# histogram
Creates a new table with a histogram based on the column name passed in.
Syntax: `histogram <column_name> ...args`
## Parameters
* `<column-name>`: name of the column to graph by
* `args`: column name to give the histogram's frequency column
## Examples
Let's say we have this file `random_numers.csv` which contains 50 random numbers.
**Note**: The input doesn't have to be numbers it works on strings too. Try it out.
```shell
> open random_numbers.csv
────┬────────────────
# │ random numbers
────┼────────────────
05
12
20
...
471
481
492
────┴────────────────
```
If we now want to see how often the different numbers were generated, we can use the `histogram` function:
```shell
> open random_numbers.csv | histogram "random numbers"
───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ percentage │ frequency
───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
008 │ 57.14% │ *********************************************************
1114 │ 100.00% │ ****************************************************************************************************
229 │ 64.29% │ ****************************************************************
336 │ 42.86% │ ******************************************
443 │ 21.43% │ *********************
5510 │ 71.43% │ ***********************************************************************
───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
We can also set the name of the second column or sort the table:
```shell
> open random_numbers.csv | histogram "random numbers" probability
───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ percentage │ probability
───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
008 │ 57.14% │ *********************************************************
1114 │ 100.00% │ ****************************************************************************************************
229 │ 64.29% │ ****************************************************************
336 │ 42.86% │ ******************************************
443 │ 21.43% │ *********************
5510 │ 71.43% │ ***********************************************************************
───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
```shell
> open random_numbers.csv | histogram "random numbers" probability | sort-by probability
───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ percentage │ probability
───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
043 │ 21.43% │ *********************
136 │ 42.86% │ ******************************************
208 │ 57.14% │ *********************************************************
329 │ 64.29% │ ****************************************************************
4510 │ 71.43% │ ***********************************************************************
5114 │ 100.00% │ ****************************************************************************************************
───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
Of course, histogram operations are not restricted to just analyzing numbers in files, you can also analyze your directories
```shell
> ls -la | histogram type | sort-by count
───┬─────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ type │ count │ percentage │ frequency
───┼─────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0 │ Dir │ 5 │ 4.76% │ ****
1 │ Symlink │ 28 │ 26.67% │ **************************
2 │ File │ 105 │ 100.00% │ ****************************************************************************************************
───┴─────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```

17
docs/commands/history.md Normal file
View File

@ -0,0 +1,17 @@
# history
Displays the last 100 commands.
## Example
```shell
> history
─────┬────────────────────────────────────────────────────────────────────────
# │
─────┼────────────────────────────────────────────────────────────────────────
...
97 │ date
98 │ ls
99 │ ls -la
─────┴────────────────────────────────────────────────────────────────────────
```

27
docs/commands/if.md Normal file
View File

@ -0,0 +1,27 @@
# if
Run blocks if a condition is true or false.
## Usage
```shell
> if <condition> <then_case> <else_case> {flags}
```
## Parameters
* `<condition>` the condition that must match
* `<then_case>` block to run if condition is true
* `<else_case>` block to run if condition is false
## Flags
* -h, --help: Display this help message
## Examples
Run a block if a condition is true
```shell
> let x = 10; if $x > 5 { echo 'greater than 5' } { echo 'less than or equal to 5' }
```
Run a block if a condition is false
```shell
> let x = 1; if $x > 5 { echo 'greater than 5' } { echo 'less than or equal to 5' }
```

39
docs/commands/inc.md Normal file
View File

@ -0,0 +1,39 @@
# inc
This command increments the value of variable by one.
## Examples
```shell
> open rustfmt.toml
─────────┬──────
edition │ 2018
─────────┴──────
```
```shell
> open rustfmt.toml | inc edition
─────────┬──────
edition │ 2019
─────────┴──────
```
```shell
> open Cargo.toml | get package.version
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.16.0
```
```shell
> open Cargo.toml | inc package.version --patch | get package.version
0.15.2
```

28
docs/commands/insert.md Normal file
View File

@ -0,0 +1,28 @@
# insert
This command adds a column to any table output. The first parameter takes the heading, the second parameter takes the value for all the rows.
## Examples
```shell
> ls | insert is_on_a_computer yes_obviously
━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified │ is_on_a_computer
───┼────────────────────────────┼──────┼──────────┼────────┼───────────┼───────────┼──────────────────
0 │ zeusiscrazy.txt │ File │ │ 556 B │ a day ago │ a day ago │ yes_obviously
1 │ coww.txt │ File │ │ 24 B │ a day ago │ a day ago │ yes_obviously
2 │ randomweirdstuff.txt │ File │ │ 197 B │ a day ago │ a day ago │ yes_obviously
3 │ abaracadabra.txt │ File │ │ 401 B │ a day ago │ a day ago │ yes_obviously
4 │ youshouldeatmorecereal.txt │ File │ │ 768 B │ a day ago │ a day ago │ yes_obviously
━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━
```
```shell
> shells | insert os linux_on_this_machine
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━
# │ │ name │ path │ os
───┼───┼────────────┼────────────────────────────────┼───────────────────────
0 │ X │ filesystem │ /home/shaurya/stuff/expr/stuff │ linux_on_this_machine
1 │ │ filesystem │ / │ linux_on_this_machine
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━
```

View File

@ -0,0 +1,57 @@
# into binary
Convert value to a binary primitive
## Usage
```shell
> into binary ...args {flags}
```
## Parameters
* ...args: column paths to convert to binary (for table input)
## Flags
* -h, --help: Display this help message
* -s, --skip <integer>: skip x number of bytes
* -b, --bytes <integer>: show y number of bytes
## Examples
convert string to a nushell binary primitive
```shell
> echo 'This is a string that is exactly 52 characters long.' | into binary
```
convert string to a nushell binary primitive
```shell
> echo 'This is a string that is exactly 52 characters long.' | into binary --skip 10
```
convert string to a nushell binary primitive
```shell
> echo 'This is a string that is exactly 52 characters long.' | into binary --skip 10 --bytes 10
```
convert a number to a nushell binary primitive
```shell
> echo 1 | into binary
```
convert a boolean to a nushell binary primitive
```shell
> echo $true | into binary
```
convert a filesize to a nushell binary primitive
```shell
> ls | where name == LICENSE | get size | into binary
```
convert a filepath to a nushell binary primitive
```shell
> ls | where name == LICENSE | get name | path expand | into binary
```
convert a decimal to a nushell binary primitive
```shell
> echo 1.234 | into binary
```

45
docs/commands/into-int.md Normal file
View File

@ -0,0 +1,45 @@
# into int
Convert value to integer
## Usage
```shell
> into int ...args {flags}
```
## Parameters
* ...args: column paths to convert to int (for table input)
## Flags
* -h, --help: Display this help message
## Examples
Convert string to integer in table
```shell
> echo [[num]; ['-5'] [4] [1.5]] | into int num
```
Convert string to integer
```shell
> echo '2' | into int
```
Convert decimal to integer
```shell
> echo 5.9 | into int
```
Convert decimal string to integer
```shell
> echo '5.9' | into int
```
Convert file size to integer
```shell
> echo 4KB | into int
```
Convert bool to integer
```shell
> echo $false $true | into int
```

View File

@ -0,0 +1,51 @@
# into string
Convert value to string
## Usage
```shell
> into string ...args {flags}
```
## Parameters
* ...args: column paths to convert to string (for table input)
## Flags
* -h, --help: Display this help message
* -d, --decimals <integer>: decimal digits to which to round
## Examples
convert decimal to string and round to nearest integer
```shell
> echo 1.7 | into string -d 0
```
convert decimal to string
```shell
> echo 4.3 | into string
```
convert string to string
```shell
> echo '1234' | into string
```
convert boolean to string
```shell
> echo $true | into string
```
convert date to string
```shell
> date now | into string
```
convert filepath to string
```shell
> ls Cargo.toml | get name | into string
```
convert filesize to string
```shell
> ls Cargo.toml | get size | into string
```

16
docs/commands/into.md Normal file
View File

@ -0,0 +1,16 @@
# into
Apply into function.
## Usage
```shell
> into <subcommand> {flags}
```
## Subcommands
* into binary - Convert value to a binary primitive
* into int - Convert value to integer
* into string - Convert value to string
## Flags
* -h, --help: Display this help message

View File

@ -0,0 +1,14 @@
# keep until
Keeps rows until the condition matches.
## Usage
```shell
> keep until <condition> {flags}
```
## Parameters
* `<condition>` The condition that must be met to stop keeping rows
## Flags
* -h, --help: Display this help message

View File

@ -0,0 +1,14 @@
# keep while
Keeps rows while the condition matches.
## Usage
```shell
> keep while <condition> {flags}
```
## Parameters
* `<condition>` The condition that must be met to keep rows
## Flags
* -h, --help: Display this help message

29
docs/commands/keep.md Normal file
View File

@ -0,0 +1,29 @@
# keep
Keep the number of rows only.
## Usage
```shell
> keep (rows) <subcommand> {flags}
```
## Subcommands
* keep until - Keeps rows until the condition matches.
* keep while - Keeps rows while the condition matches.
## Parameters
* `(rows)` Starting from the front, the number of rows to keep
## Flags
* -h, --help: Display this help message
## Examples
Keep the first row
```shell
> echo [1 2 3] | keep
```
Keep the first four rows
```shell
> echo [1 2 3 4 5] | keep 4
```

34
docs/commands/kill.md Normal file
View File

@ -0,0 +1,34 @@
# kill
Kill a process using the process id.
## Usage
```shell
> kill <pid> ...args {flags}
```
## Parameters
* `<pid>` process id of process that is to be killed
* ...args: rest of processes to kill
## Flags
* -h, --help: Display this help message
* -f, --force: forcefully kill the process
* -q, --quiet: won't print anything to the console
* -s, --signal <integer>: signal decimal number to be sent instead of the default 15 (unsupported on Windows)
## Examples
Kill the pid using the most memory
```shell
> ps | sort-by mem | last | each { kill $it.pid }
```
Force kill a given pid
```shell
> kill --force 12345
```
Send INT signal
```shell
> kill -s 2 12345
```

Some files were not shown because too many files have changed in this diff Show More