diff --git a/docs/commands/config.md b/docs/commands/config.md new file mode 100644 index 000000000..cae8e43ef --- /dev/null +++ b/docs/commands/config.md @@ -0,0 +1,47 @@ +# config + +Configuration management. + +Syntax: `config {flags}` + +### Flags + + + --load + load the config from the path give + + --set + set a value in the config, eg) --set [key value] + + --set_into + sets a variable from values in the pipeline + + --get + get a value from the config + + --remove + 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 | + +## 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://book.nushell.sh/en/configuration). diff --git a/docs/commands/format.md b/docs/commands/format.md new file mode 100644 index 000000000..836f25b98 --- /dev/null +++ b/docs/commands/format.md @@ -0,0 +1,37 @@ +# format + +Format columns into a string using a simple pattern + +Syntax: `format ` + +### Parameters + +* ``: 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 +━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/from-tsv.md b/docs/commands/from-tsv.md new file mode 100644 index 000000000..86452de97 --- /dev/null +++ b/docs/commands/from-tsv.md @@ -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 +━━━━┷━━━━━━━━━┷━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/from-xml.md b/docs/commands/from-xml.md new file mode 100644 index 000000000..d7a9e2a78 --- /dev/null +++ b/docs/commands/from-xml.md @@ -0,0 +1,34 @@ +# from-xml + +Parse text as `.xml` and create table. Use this when nushell cannot dertermine 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 + + + Africa + Antarctica + Asia + Australia + Europe + North America + South America + +``` + +We can use `from-xml` to read the input like a `xml` file: + +```shell +> open world.txt | from-xml +━━━━━━━━━━━━━━━━ + world +──────────────── + [table 7 rows] +━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/from-yaml.md b/docs/commands/from-yaml.md index 1c81c7dc9..1c7e9fef7 100644 --- a/docs/commands/from-yaml.md +++ b/docs/commands/from-yaml.md @@ -1,6 +1,6 @@ # from-yaml -Parse text as `.yaml/.yml` and create table. +Parse text as `.yaml/.yml` and create table. Use this when nushell cannot determine the input file extension. Syntax: `from-yaml` diff --git a/docs/commands/get.md b/docs/commands/get.md new file mode 100644 index 000000000..5ab472130 --- /dev/null +++ b/docs/commands/get.md @@ -0,0 +1,54 @@ +# get + +Open given cells as text. + +Syntax: `get ...args` + +### Parameters: + +* `args`: optionally return additional data by path + +## Examples + +If we run `sys` we recieve a table which contains tables itself: + +```shell +> sys +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━ + host │ cpu │ disks │ mem │ temp │ net │ battery +────────────────────────────────────────┼────────────────────────────────────┼────────────────┼───────────────────────────────────────┼────────────────┼────────────────┼──────────────── + [row arch hostname name release uptime │ [row cores current ghz max ghz min │ [table 7 rows] │ [row free swap free swap total total] │ [table 6 rows] │ [table 3 rows] │ [table 1 rows] + users] │ ghz] │ │ │ │ │ +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━ +``` + +To access one of the embeded tables we can use the `get` command + +```shell +> sys | get cpu +━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + cores │ current ghz │ min ghz │ max ghz +───────┼───────────────────┼────────────────────┼─────────────────── + 4 │ 1.530000000000000 │ 0.5000000000000000 │ 3.500000000000000 +━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ +``` +```shell +> sys | get battery +━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━ + vendor │ model │ mins to full +────────┼──────────┼────────────────── + SMP │ L14M2P21 │ 16.7024000000000 +━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━ +``` + +There's also the ability to pass multiple parameters to `get` which results in an output like this + +```shell +sys | get cpu battery +━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + # │ cores │ current ghz │ min ghz │ max ghz │ vendor │ model │ mins to full +───┼───────┼───────────────────┼────────────────────┼───────────────────┼────────┼──────────┼─────────────────── + 0 │ 4 │ 1.500000000000000 │ 0.5000000000000000 │ 3.500000000000000 │ │ │ + 1 │ │ │ │ │ SMP │ L14M2P21 │ 16.94503000000000 +━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/ps.md b/docs/commands/ps.md new file mode 100644 index 000000000..abf0b0714 --- /dev/null +++ b/docs/commands/ps.md @@ -0,0 +1,25 @@ +# ps + +This command shows information about system processes. + +Syntax: `ps` + +## Example + +```shell +> ps +... +━━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + # │ pid │ name │ status │ cpu +────┼───────┼────────────────────────────────────────────────────────────────────┼─────────┼─────────────────── + 50 │ 10184 │ firefox.exe │ Running │ 0.000000000000000 + 51 │ 11584 │ WindowsTerminal.exe │ Running │ 0.000000000000000 + 52 │ 11052 │ conhost.exe │ Running │ 0.000000000000000 + 53 │ 7076 │ nu.exe │ Running │ 0.000000000000000 + ... + 66 │ 3000 │ Code.exe │ Running │ 0.000000000000000 + 67 │ 5388 │ conhost.exe │ Running │ 0.000000000000000 + 68 │ 6268 │ firefox.exe │ Running │ 0.000000000000000 + 69 │ 8972 │ nu_plugin_ps.exe │ Running │ 58.00986000000000 +━━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/save.md b/docs/commands/save.md new file mode 100644 index 000000000..fe1ce66ef --- /dev/null +++ b/docs/commands/save.md @@ -0,0 +1,30 @@ +# save + +This command saves the contents of the pipeline to a file. Use this in combination with the `to-json`, `to-csv`, ... commands to save the contents in the specified format. + +Syntax: `save (path) {flags}` + +### Parameters: + +* `(path)` the path to save contents to + +### Flags + + --raw + treat values as-is rather than auto-converting based on file extension + +## Example + +You can save the name of files in a directory like this: + +```shell +> ls | where type == File | pick name | save filenames.csv +``` + +Or you can format it in supported formats using one of the `to-*` commands: + +```shell +> ls | where type == File | pick name | to-csv | save filenames +``` + +`filename.csv` and `filenames` are both `csv` formatted files. Nu auto-converts the format if a supported file extension is given. \ No newline at end of file