forked from extern/nushell
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
5676713b1f | |||
b59231d32b | |||
e530cf0a9d | |||
1ba69e4b11 | |||
f10390b1be | |||
c2b1908644 | |||
0a93335f6d | |||
8e7acd1094 | |||
c6ee6273db | |||
c77059f891 | |||
5bdda06ca6 | |||
d8303dd6d6 | |||
60ec68b097 | |||
deae66c194 | |||
0845572878 |
2636
Cargo.lock
generated
2636
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "nu"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>", "Jonathan Turner <jonathan.d.turner@gmail.com>", "Andrés N. Robalino <andres@androbtech.com>"]
|
||||
description = "A shell for the GitHub era"
|
||||
license = "MIT"
|
||||
|
@ -173,7 +173,7 @@ We can pipeline this into a command that gets the contents of one of the columns
|
||||
━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━┯━━━━━━━━━
|
||||
authors │ description │ edition │ license │ name │ version
|
||||
─────────────────┼────────────────────────────┼─────────┼─────────┼──────┼─────────
|
||||
[table: 3 rows] │ A shell for the GitHub era │ 2018 │ MIT │ nu │ 0.6.0
|
||||
[table: 3 rows] │ A shell for the GitHub era │ 2018 │ MIT │ nu │ 0.6.1
|
||||
━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━┷━━━━━━━━━
|
||||
```
|
||||
|
||||
@ -181,7 +181,7 @@ Finally, we can use commands outside of Nu once we have the data we want:
|
||||
|
||||
```
|
||||
/home/jonathan/Source/nushell(master)> open Cargo.toml | get package.version | echo $it
|
||||
0.6.0
|
||||
0.6.1
|
||||
```
|
||||
|
||||
Here we use the variable `$it` to refer to the value being piped to the external command.
|
||||
|
@ -9,22 +9,22 @@ Exits the nu shell. If you have multiple nu shells, use `exit --now` to exit all
|
||||
```
|
||||
|
||||
```
|
||||
/home/username/stuff/books> shells
|
||||
---+---+------------+----------------------------
|
||||
# | | name | path
|
||||
---+---+------------+----------------------------
|
||||
0 | | filesystem | /home/username/stuff/notes
|
||||
1 | | filesystem | /home/username/stuff/videos
|
||||
2 | X | filesystem | /home/username/stuff/books
|
||||
---+---+------------+----------------------------
|
||||
/home/username/stuff/books> exit
|
||||
/home/username/stuff/videos> shells
|
||||
---+---+------------+----------------------------
|
||||
# | | name | path
|
||||
---+---+------------+----------------------------
|
||||
0 | | filesystem | /home/username/stuff/notes
|
||||
1 | X | filesystem | /home/username/stuff/videos
|
||||
---+---+------------+----------------------------
|
||||
/home/username/stuff/videos> exit --now
|
||||
> 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
|
||||
```
|
||||
|
33
docs/commands/from-json.md
Normal file
33
docs/commands/from-json.md
Normal file
@ -0,0 +1,33 @@
|
||||
# from-json
|
||||
|
||||
Parse text as `.json` and create table. Use this when nushell cannot dertermine 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 │ command │ Yes
|
||||
━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━
|
||||
```
|
24
docs/commands/from-yaml.md
Normal file
24
docs/commands/from-yaml.md
Normal file
@ -0,0 +1,24 @@
|
||||
# from-yaml
|
||||
|
||||
Parse text as `.yaml/.yml` and create table.
|
||||
|
||||
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
|
||||
━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━
|
||||
|
||||
```
|
80
docs/commands/histogram.md
Normal file
80
docs/commands/histogram.md
Normal file
@ -0,0 +1,80 @@
|
||||
# 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
|
||||
open random_numbers2.csv
|
||||
━━━━┯━━━━━━━━━━━━━━━━
|
||||
# │ random numbers
|
||||
────┼────────────────
|
||||
0 │ 0
|
||||
1 │ 5
|
||||
2 │ 5
|
||||
...
|
||||
47 │ 0
|
||||
48 │ 2
|
||||
49 │ 4
|
||||
━━━━┷━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
If we now want to see how often the different numbers were generated, we can use the `histogram` function:
|
||||
|
||||
```shell
|
||||
> open random_numbers2.csv | histogram "random numbers"
|
||||
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ random numbers │ frequency
|
||||
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
0 │ 0 │ ****************************************************************************************************
|
||||
1 │ 1 │ ******************************
|
||||
2 │ 2 │ *************************************************************
|
||||
3 │ 3 │ *********************************************************************
|
||||
4 │ 4 │ *****************************************************
|
||||
5 │ 5 │ *********************************************************************
|
||||
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
We can also set the name of the second column or sort the table:
|
||||
|
||||
```shell
|
||||
> open random_numbers2.csv | histogram "random numbers" probability
|
||||
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ random numbers │ probability
|
||||
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
0 │ 0 │ ****************************************************************************************************
|
||||
1 │ 1 │ ******************************
|
||||
2 │ 2 │ *************************************************************
|
||||
3 │ 3 │ *********************************************************************
|
||||
4 │ 4 │ *****************************************************
|
||||
5 │ 5 │ *********************************************************************
|
||||
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
```
|
||||
|
||||
```shell
|
||||
> open random_numbers2.csv | histogram "random numbers" probability | sort-by probability
|
||||
━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ random numbers │ probability
|
||||
───┼────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
0 │ 1 │ ******************************
|
||||
1 │ 4 │ *****************************************************
|
||||
2 │ 2 │ *************************************************************
|
||||
3 │ 3 │ *********************************************************************
|
||||
4 │ 5 │ *********************************************************************
|
||||
5 │ 0 │ ****************************************************************************************************
|
||||
━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
```
|
17
docs/commands/history.md
Normal file
17
docs/commands/history.md
Normal file
@ -0,0 +1,17 @@
|
||||
# history
|
||||
|
||||
Displays the last 100 commands.
|
||||
|
||||
## Example
|
||||
|
||||
```shell
|
||||
> history
|
||||
━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ <value>
|
||||
────┼───────────────────────────────────────────────────────────────────────────
|
||||
...
|
||||
97 │ ls
|
||||
98 │ ls | where accessed < 1d
|
||||
99 │ cd
|
||||
━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
@ -6,17 +6,17 @@ This command increments the value of variable by one.
|
||||
|
||||
```shell
|
||||
> open rustfmt.toml
|
||||
---------
|
||||
━━━━━━━━━
|
||||
edition
|
||||
---------
|
||||
─────────
|
||||
2018
|
||||
---------
|
||||
━━━━━━━━━
|
||||
> open rustfmt.toml | inc edition
|
||||
---------
|
||||
━━━━━━━━━
|
||||
edition
|
||||
---------
|
||||
─────────
|
||||
2019
|
||||
---------
|
||||
━━━━━━━━━
|
||||
```
|
||||
|
||||
```shell
|
||||
|
@ -3,10 +3,13 @@
|
||||
This command returns the nth row of a table, starting from 0.
|
||||
If the number given is less than 0 or more than the number of rows, nothing is returned.
|
||||
|
||||
## Usage
|
||||
### Usage
|
||||
```shell
|
||||
> [input-command] | nth [row-number]
|
||||
> [input-command] | nth <row number> ...args
|
||||
```
|
||||
### Parameters:
|
||||
* `<row number>` the number of the row to return
|
||||
* `args`: Optionally return more rows
|
||||
|
||||
## Examples
|
||||
```shell
|
||||
@ -21,11 +24,19 @@ If the number given is less than 0 or more than the number of rows, nothing is r
|
||||
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
||||
|
||||
> ls | nth 0
|
||||
━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
|
||||
name │ type │ readonly │ size │ accessed │ modified
|
||||
────────────┼──────┼──────────┼────────┼───────────────┼───────────────
|
||||
Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
|
||||
━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
||||
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
|
||||
# │ name │ type │ readonly │ size │ accessed │ modified
|
||||
───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
|
||||
0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
|
||||
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
||||
|
||||
> ls | nth 0 2
|
||||
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
|
||||
# │ name │ type │ readonly │ size │ accessed │ modified
|
||||
───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
|
||||
0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
|
||||
2 │ .gitignore │ File │ │ 19 B │ 2 minutes ago │ 2 minutes ago
|
||||
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
|
||||
|
||||
> ls | nth 5
|
||||
```
|
@ -6,21 +6,21 @@ Lists all the active nu shells with a number/index, a name and the path. Also ma
|
||||
|
||||
```
|
||||
> shells
|
||||
---+---+------------+---------------
|
||||
# | | name | path
|
||||
---+---+------------+---------------
|
||||
0 | | filesystem | /usr
|
||||
1 | | filesystem | /home
|
||||
2 | X | filesystem | /home/username
|
||||
---+---+------------+---------------
|
||||
━━━┯━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ │ name │ path
|
||||
───┼───┼────────────┼─────────────────────────────────────
|
||||
0 │ │ filesystem │ /home/jonathanturner/Source/nushell
|
||||
1 │ │ filesystem │ /usr
|
||||
2 │ X │ filesystem │ /home
|
||||
━━━┷━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
```
|
||||
/> shells
|
||||
---+---+-------------------------------------------------+------------------------------------
|
||||
# | | name | path
|
||||
---+---+-------------------------------------------------+------------------------------------
|
||||
0 | | filesystem | /Users/username/Code/nushell
|
||||
1 | X | {/Users/username/Code/nushell/Cargo.toml} | /
|
||||
---+---+-------------------------------------------------+------------------------------------
|
||||
━━━┯━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# │ │ name │ path
|
||||
───┼───┼──────────────────────────────────────────────────┼─────────────────────────────────────
|
||||
0 │ │ filesystem │ /home/jonathanturner/Source/nushell
|
||||
1 │ X │ {/home/jonathanturner/Source/nushell/Cargo.toml} │ /
|
||||
━━━┷━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
# env
|
||||
# sort-by
|
||||
|
||||
The `sort-by` command sorts the table being displayed in the terminal by a chosen column(s).
|
||||
|
||||
|
72
docs/commands/split-column.md
Normal file
72
docs/commands/split-column.md
Normal file
@ -0,0 +1,72 @@
|
||||
# split-column
|
||||
|
||||
Split row contents across multiple columns via the separator.
|
||||
|
||||
Syntax: `split-column <separator> ...args{flags}`
|
||||
|
||||
### Parameters
|
||||
|
||||
* `<seperator>`: string that denotes what separates columns
|
||||
* `args`: column names to give the new columns. If not specified they will be set to `Column1` `Column2` ...
|
||||
|
||||
### Flags
|
||||
|
||||
--collapse-empty
|
||||
Removes empty columns
|
||||
|
||||
## Examples
|
||||
|
||||
If we have file structured like this:
|
||||
|
||||
```shell
|
||||
0.12643678160919541 | 0.6851851851851852 | 0.273972602739726
|
||||
0.28735632183908044 | 0.09259259259259259 | 0.6986301369863014
|
||||
0.8045977011494253 | 0.8148148148148148 | 0.7397260273972602
|
||||
0.28735632183908044 | 0.09259259259259259 | 0.547945205479452
|
||||
0.6896551724137931 | 0.7037037037037037 | 1.2465753424657535
|
||||
0.6896551724137931 | 0.8333333333333334 | 0.4657534246575342
|
||||
0.9080459770114943 | 1.3333333333333333 | 0.4931506849315068
|
||||
0.9310344827586207 | 1.1296296296296295 | 0.7123287671232876
|
||||
0.3448275862068966 | 0.018518518518518517 | 0.6575342465753424
|
||||
1.0459770114942528 | 1.0925925925925926 | 0.6164383561643836
|
||||
```
|
||||
|
||||
We can build a table from it using the `split-column` command
|
||||
|
||||
```shell
|
||||
> open coordinates.txt | lines | split-column " | "
|
||||
━━━┯━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━
|
||||
# │ Column1 │ Column2 │ Column3
|
||||
───┼─────────────────────┼──────────────────────┼────────────────────
|
||||
0 │ 0.12643678160919541 │ 0.6851851851851852 │ 0.273972602739726
|
||||
1 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.6986301369863014
|
||||
2 │ 0.8045977011494253 │ 0.8148148148148148 │ 0.7397260273972602
|
||||
3 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.547945205479452
|
||||
4 │ 0.6896551724137931 │ 0.7037037037037037 │ 1.2465753424657535
|
||||
5 │ 0.6896551724137931 │ 0.8333333333333334 │ 0.4657534246575342
|
||||
6 │ 0.9080459770114943 │ 1.3333333333333333 │ 0.4931506849315068
|
||||
7 │ 0.9310344827586207 │ 1.1296296296296295 │ 0.7123287671232876
|
||||
8 │ 0.3448275862068966 │ 0.018518518518518517 │ 0.6575342465753424
|
||||
9 │ 1.0459770114942528 │ 1.0925925925925926 │ 0.6164383561643836
|
||||
━━━┷━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
And give names to the columns
|
||||
|
||||
```shell
|
||||
> open coordinates.txt | lines | split-column " | " x y z
|
||||
━━━┯━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━
|
||||
# │ x │ y │ z
|
||||
───┼─────────────────────┼──────────────────────┼────────────────────
|
||||
0 │ 0.12643678160919541 │ 0.6851851851851852 │ 0.273972602739726
|
||||
1 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.6986301369863014
|
||||
2 │ 0.8045977011494253 │ 0.8148148148148148 │ 0.7397260273972602
|
||||
3 │ 0.28735632183908044 │ 0.09259259259259259 │ 0.547945205479452
|
||||
4 │ 0.6896551724137931 │ 0.7037037037037037 │ 1.2465753424657535
|
||||
5 │ 0.6896551724137931 │ 0.8333333333333334 │ 0.4657534246575342
|
||||
6 │ 0.9080459770114943 │ 1.3333333333333333 │ 0.4931506849315068
|
||||
7 │ 0.9310344827586207 │ 1.1296296296296295 │ 0.7123287671232876
|
||||
8 │ 0.3448275862068966 │ 0.018518518518518517 │ 0.6575342465753424
|
||||
9 │ 1.0459770114942528 │ 1.0925925925925926 │ 0.6164383561643836
|
||||
━━━┷━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
34
docs/commands/split-row.md
Normal file
34
docs/commands/split-row.md
Normal file
@ -0,0 +1,34 @@
|
||||
# split-row
|
||||
|
||||
Split row contents over multiple rows via the separator.
|
||||
|
||||
Syntax: `split-row <separator>`
|
||||
|
||||
### Parameters:
|
||||
* `<separator>` the character that denotes what separates rows
|
||||
|
||||
## Examples
|
||||
|
||||
We can build a table from a file that looks like this
|
||||
|
||||
```shell
|
||||
> open table.txt
|
||||
4, 0, 2, 0, 7, 8
|
||||
|
||||
```
|
||||
|
||||
using the `split-row` command.
|
||||
|
||||
```shell
|
||||
open table.txt | split-row ", "
|
||||
━━━┯━━━━━━━━━
|
||||
# │ <value>
|
||||
───┼─────────
|
||||
0 │ 4
|
||||
1 │ 0
|
||||
2 │ 2
|
||||
3 │ 0
|
||||
4 │ 7
|
||||
5 │ 8
|
||||
━━━┷━━━━━━━━━
|
||||
```
|
@ -9,6 +9,6 @@ Outputs the nushell version.
|
||||
━━━━━━━━━
|
||||
version
|
||||
─────────
|
||||
0.3.0
|
||||
0.6.0
|
||||
━━━━━━━━━
|
||||
```
|
||||
|
@ -2,6 +2,39 @@
|
||||
|
||||
This command filters the content of a table based on a condition passed as a parameter, which must be a boolean expression making use of any of the table columns. Other commands such as `ls` are capable of feeding `where` with their output through pipelines.
|
||||
|
||||
Where has two general forms:
|
||||
- `where <column_name> <comparison> <value>`
|
||||
- `where <column_name>`
|
||||
|
||||
## Where with comparison
|
||||
|
||||
In the first form, `where` is passed a column name that the filter will run against. Next, is the operator used to compare this column to its value. The following operators are supported:
|
||||
|
||||
- `<` (less than)
|
||||
- `<=` (less than or equal)
|
||||
- `>` (greater than)
|
||||
- `>=` (greater than or equal)
|
||||
- `!=` (not equal)
|
||||
- `==` (equal)
|
||||
|
||||
Strings have two additional operators:
|
||||
- `=~` (fuzzy match to allow)
|
||||
- `!~` (fuzzy match to not allow)
|
||||
|
||||
Dates can also be compared using the duration types. For example, `where accessed > 2w` will check the date in accessed to see if it's greater than 2 weeks ago. Durations currently allow these abbreviations:
|
||||
|
||||
- `1s` (one second)
|
||||
- `1m` (one minute)
|
||||
- `1h` (one hour)
|
||||
- `1d` (one day)
|
||||
- `1w` (one week)
|
||||
- `1M` (one month)
|
||||
- `1y` (one year)
|
||||
|
||||
## Boolean check
|
||||
|
||||
Where with the form `| where readonly` is used to check boolean values. For example, the command `ls --full | where readonly` will list only those files that are readonly.
|
||||
|
||||
## Usage
|
||||
```shell
|
||||
> [input-command] | where [condition]
|
||||
@ -11,24 +44,47 @@ This command filters the content of a table based on a condition passed as a par
|
||||
|
||||
```shell
|
||||
> ls | where size > 4kb
|
||||
----+----------------+------+----------+----------+----------------+----------------
|
||||
# | name | type | readonly | size | accessed | modified
|
||||
----+----------------+------+----------+----------+----------------+----------------
|
||||
0 | IMG_1291.jpg | File | | 115.5 KB | a month ago | 4 months ago
|
||||
1 | README.md | File | | 11.1 KB | 2 days ago | 2 days ago
|
||||
2 | IMG_1291.png | File | | 589.0 KB | a month ago | a month ago
|
||||
3 | IMG_1381.jpg | File | | 81.0 KB | a month ago | 4 months ago
|
||||
4 | butterfly.jpeg | File | | 4.2 KB | a month ago | a month ago
|
||||
5 | Cargo.lock | File | | 199.6 KB | 22 minutes ago | 22 minutes ago
|
||||
━━━┯━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━
|
||||
# │ name │ type │ size │ created │ accessed │ modified
|
||||
───┼────────────┼──────┼─────────┼─────────────┼─────────────┼─────────────
|
||||
0 │ Cargo.lock │ File │ 87.2 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago
|
||||
1 │ README.md │ File │ 19.5 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago
|
||||
2 │ Cargo.toml │ File │ 4.7 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago
|
||||
━━━┷━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
```shell
|
||||
> ps | where cpu > 10
|
||||
---+-------+----------+-------+-----------------------------
|
||||
# | pid | status | cpu | name
|
||||
---+-------+----------+-------+-----------------------------
|
||||
0 | 1992 | Sleeping | 44.52 | /usr/bin/gnome-shell
|
||||
1 | 1069 | Sleeping | 16.15 |
|
||||
2 | 24116 | Sleeping | 13.70 | /opt/google/chrome/chrome
|
||||
3 | 21976 | Sleeping | 12.67 | /usr/share/discord/Discord
|
||||
> ps | where cpu > 0
|
||||
━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
|
||||
# │ pid │ name │ status │ cpu
|
||||
───┼───────┼───────────────────────┼──────────┼───────────────────
|
||||
0 │ 1546 │ Xorg │ Sleeping │ 10.65405000000000
|
||||
1 │ 1769 │ gnome-shell │ Sleeping │ 5.271094000000000
|
||||
2 │ 2153 │ gnome-terminal-server │ Sleeping │ 5.193664000000000
|
||||
3 │ 13556 │ nu_plugin_ps │ Sleeping │ 40.70250000000000
|
||||
━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
```shell
|
||||
> ls | where accessed <= 1w
|
||||
━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━
|
||||
# │ name │ type │ size │ accessed │ modified
|
||||
───┼───────────────┼───────────┼──────────┼────────────┼────────────
|
||||
0 │ Cargo.toml │ File │ 4.7 KB │ 2 days ago │ 2 days ago
|
||||
1 │ target │ Directory │ 4.1 KB │ 2 days ago │ 2 days ago
|
||||
2 │ Makefile.toml │ File │ 449 B │ 4 days ago │ 4 days ago
|
||||
3 │ README.md │ File │ 19.5 KB │ 2 days ago │ 2 days ago
|
||||
4 │ Cargo.lock │ File │ 170.7 KB │ 2 days ago │ 2 days ago
|
||||
5 │ crates │ Directory │ 4.1 KB │ 2 days ago │ 2 days ago
|
||||
6 │ TODO.md │ File │ 1.3 KB │ 2 days ago │ 2 days ago
|
||||
━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
```shell
|
||||
> ls | where name =~ "yml"
|
||||
━━━━━━━━━━━━━┯━━━━━━┯━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━
|
||||
name │ type │ size │ accessed │ modified
|
||||
─────────────┼──────┼───────┼────────────┼────────────
|
||||
.gitpod.yml │ File │ 780 B │ a week ago │ a week ago
|
||||
━━━━━━━━━━━━━┷━━━━━━┷━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━
|
||||
```
|
||||
|
@ -396,6 +396,7 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
||||
let colored_prompt = {
|
||||
#[cfg(feature = "starship-prompt")]
|
||||
{
|
||||
std::env::set_var("STARSHIP_SHELL", "");
|
||||
starship::print::get_prompt(starship::context::Context::new_with_dir(
|
||||
clap::ArgMatches::default(),
|
||||
cwd,
|
||||
|
Reference in New Issue
Block a user