mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Add example for command n,g,p and grid, update date now examples (#4622)
This commit is contained in:
@ -16,3 +16,13 @@ Get the current date and display it in a given format string.
|
||||
```shell
|
||||
> date now | date format "%Y-%m-%d %H:%M:%S"
|
||||
```
|
||||
|
||||
Get the time duration from 2019-04-30 to now
|
||||
```shell
|
||||
> (date now) - 2019-05-01
|
||||
```
|
||||
|
||||
Get the time duration since a more accurate time
|
||||
```shell
|
||||
> (date now) - 2019-05-01T04:12:05.20+08:00
|
||||
```
|
||||
|
@ -13,3 +13,15 @@ Switch to a given shell.
|
||||
## Parameters
|
||||
|
||||
- `shell_number`: shell number to change to
|
||||
|
||||
## Examples
|
||||
|
||||
Make two directories and enter new shells for them, use `g` to jump to the specific shell
|
||||
```shell
|
||||
> mkdir foo bar; enter foo; enter ../bar; g 1
|
||||
```
|
||||
|
||||
Use `shells` to show all the opened shells and run `g 2` to jump to the third one
|
||||
```shell
|
||||
> shells; g 2
|
||||
```
|
||||
|
@ -15,3 +15,30 @@ Renders the output to a textual terminal grid.
|
||||
- `--width {int}`: number of terminal columns wide (not output columns)
|
||||
- `--color`: draw output with color
|
||||
- `--separator {string}`: character to separate grid with
|
||||
|
||||
## Examples
|
||||
|
||||
Render a simple list to a grid
|
||||
```shell
|
||||
> [1 2 3 a b c] | grid
|
||||
```
|
||||
|
||||
The above example is the same as:
|
||||
```shell
|
||||
> [1 2 3 a b c] | wrap name | grid
|
||||
```
|
||||
|
||||
Render a record to a grid
|
||||
```shell
|
||||
> {name: 'foo', b: 1, c: 2} | grid
|
||||
```
|
||||
|
||||
Render a list of records to a grid
|
||||
```shell
|
||||
> [{name: 'A', v: 1} {name: 'B', v: 2} {name: 'C', v: 3}] | grid
|
||||
```
|
||||
|
||||
Render a table with 'name' column in it to a grid
|
||||
```shell
|
||||
> [[name patch]; [0.1.0 $false] [0.1.1 $true] [0.2.0 $false]] | grid
|
||||
```
|
||||
|
@ -9,3 +9,15 @@ Switch to the next shell.
|
||||
## Signature
|
||||
|
||||
```> n ```
|
||||
|
||||
## Examples
|
||||
|
||||
Make two directories and enter new shells for them, use `n` to jump to the next shell
|
||||
```shell
|
||||
> mkdir foo bar; enter foo; enter ../bar; n
|
||||
```
|
||||
|
||||
Run `n` several times and note the changes of current directory
|
||||
```shell
|
||||
> n
|
||||
```
|
||||
|
@ -9,3 +9,15 @@ Switch to the previous shell.
|
||||
## Signature
|
||||
|
||||
```> p ```
|
||||
|
||||
## Examples
|
||||
|
||||
Make two directories and enter new shells for them, use `p` to jump to the previous shell
|
||||
```shell
|
||||
> mkdir foo bar; enter foo; enter ../bar; p
|
||||
```
|
||||
|
||||
Run `p` several times and note the changes of current directory
|
||||
```shell
|
||||
> p
|
||||
```
|
||||
|
@ -20,8 +20,8 @@ Update the table cells.
|
||||
Update the zero value cells to empty strings.
|
||||
```shell
|
||||
> [
|
||||
[2021-04-16, 2021-06-10, 2021-09-18, 2021-10-15, 2021-11-16, 2021-11-17, 2021-11-18];
|
||||
[ 37, 0, 0, 0, 37, 0, 0]
|
||||
["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"];
|
||||
[ 37, 0, 0, 0, 37, 0, 0]
|
||||
] | update cells {|value|
|
||||
if $value == 0 {
|
||||
""
|
||||
@ -34,8 +34,8 @@ Update the zero value cells to empty strings.
|
||||
Update the zero value cells to empty strings in 2 last columns.
|
||||
```shell
|
||||
> [
|
||||
[2021-04-16, 2021-06-10, 2021-09-18, 2021-10-15, 2021-11-16, 2021-11-17, 2021-11-18];
|
||||
[ 37, 0, 0, 0, 37, 0, 0]
|
||||
["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"];
|
||||
[ 37, 0, 0, 0, 37, 0, 0]
|
||||
] | update cells -c ["2021-11-18", "2021-11-17"] {|value|
|
||||
if $value == 0 {
|
||||
""
|
||||
|
Reference in New Issue
Block a user