Structured Data
And how are we going to take advantage of all this?
# help commands is our man inside nushell, let's navigate through it to understand some basic concepts already.
help commands
โญโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโฎ
โ # โ name โ category โ command_type โ description โ ... โ
โโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโค
โ 0 โ alias โ core โ keyword โ Alias a command (with optional flags) to a new name. โ ... โ
โ 1 โ all โ filters โ built-in โ Test if every element of the input fulfills a predicate โ ... โ
โ โ โ โ โ expression. โ โ
โ 2 โ ansi โ platform โ built-in โ Output ANSI codes to change color and style of text. โ ... โ
โ 3 โ ansi gradient โ platform โ built-in โ Add a color gradient (using ANSI color codes) to the given โ ... โ
โ โ โ โ โ string. โ โ
โ 4 โ ansi link โ platform โ built-in โ Add a link (using OSC 8 escape sequence) to the given โ ... โ
โ โ โ โ โ string. โ โ
### Output too large we have more than 400 lines, I cut...
To enter one of these lines we need to point to which one we want. If we want the first one we can just do this.
~> help commands | first
โญโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ name โ alias โ
โ category โ core โ
โ command_type โ keyword โ
โ description โ Alias a command (with optional flags) to a new name. โ
โ โ โญโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ params โ โ # โ name โ type โ required โ description โ โ
โ โ โโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ โ โ 0 โ name โ string โ true โ Name of the alias. โ โ
โ โ โ 1 โ initial_value โ "=" expression โ true โ Equals sign followed by value. โ โ
โ โ โ 2 โ --help(-h) โ switch โ false โ Display the help message for this command โ โ
โ โ โฐโโโโดโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ โญโโโโฌโโโโโโโโโโฌโโโโโโโโโโฎ โ
โ input_output โ โ # โ input โ output โ โ
โ โ โโโโโผโโโโโโโโโโผโโโโโโโโโโค โ
โ โ โ 0 โ nothing โ nothing โ โ
โ โ โฐโโโโดโโโโโโโโโโดโโโโโโโโโโฏ โ
โ search_terms โ abbr, aka, fn, func, function โ
โ is_const โ false
But we can point to the one we want directly using get. I already saw that ls is on line 201 so...
~> help commands | get 201
โญโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ name โ ls โ
โ category โ filesystem โ
โ command_type โ built-in โ
โ description โ List the filenames, sizes, and modification times of items in a directory. โ
โ โ โญโโโโฌโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ params โ โ # โ name โ type โ required โ description โ โ
โ โ โโโโโผโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ โ โ 0 โ ...pattern โ one_of(glob, string) โ false โ The glob pattern to use. โ โ
โ โ โ 1 โ --help(-h) โ switch โ false โ Display the help message for this command โ โ
โ โ โ 2 โ --all(-a) โ switch โ false โ Show hidden files โ โ
โ โ โ 3 โ --long(-l) โ switch โ false โ Get all available columns for each entry (slower; โ โ
โ โ โ โ โ โ โ columns are platform-dependent) โ โ
โ โ โ 4 โ --short-names(-s) โ switch โ false โ Only print the file names, and not the path โ โ
โ โ โ 5 โ --full-paths(-f) โ switch โ false โ display paths as absolute paths โ โ
โ โ โ 6 โ --du(-d) โ switch โ false โ Display the apparent directory size ("disk usage") โ โ
โ โ โ โ โ โ โ in place of the directory metadata size โ โ
โ โ โ 7 โ --directory(-D) โ switch โ false โ List the specified directory itself instead of its โ โ
โ โ โ โ โ โ โ contents โ โ
โ โ โ 8 โ --mime-type(-m) โ switch โ false โ Show mime-type in type column instead of 'file' โ โ
โ โ โ โ โ โ โ (based on filenames only; files' contents are not โ โ
โ โ โ โ โ โ โ examined) โ โ
โ โ โ 9 โ --threads(-t) โ switch โ false โ Use multiple threads to list contents. Output will โ โ
โ โ โ โ โ โ โ be non-deterministic. โ โ
โ โ โฐโโโโดโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ โญโโโโฌโโโโโโโโโโฌโโโโโโโโโฎ โ
โ input_output โ โ # โ input โ output โ โ
โ โ โโโโโผโโโโโโโโโโผโโโโโโโโโค โ
โ โ โ 0 โ nothing โ table โ โ
โ โ โฐโโโโดโโโโโโโโโโดโโโโโโโโโฏ โ
โ search_terms โ dir โ
โ is_const โ false โ
โฐโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโ
But we could also filter by name, which would give us a single line and then use first with the command help commands | where name == ls | first. It would be the same output as above.
We can observe that we have structured data too and we can already navigate through them using get.
~> help commands | where name == ls | first | get description
List the filenames, sizes, and modification times of items in a directory.
# Or even the params which already have greater complexity.
~> help commands | where name == ls | first | get params
โญโโโโฌโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ # โ name โ type โ required โ description โ
โโโโโผโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 0 โ ...pattern โ one_of(glob, string) โ false โ The glob pattern to use. โ
โ 1 โ --help(-h) โ switch โ false โ Display the help message for this command โ
โ 2 โ --all(-a) โ switch โ false โ Show hidden files โ
โ 3 โ --long(-l) โ switch โ false โ Get all available columns for each entry (slower; columns are โ
โ โ โ โ โ platform-dependent) โ
โ 4 โ --short-names(-s) โ switch โ false โ Only print the file names, and not the path โ
โ 5 โ --full-paths(-f) โ switch โ false โ display paths as absolute paths โ
โ 6 โ --du(-d) โ switch โ false โ Display the apparent directory size ("disk usage") in place of the โ
โ โ โ โ โ directory metadata size โ
โ 7 โ --directory(-D) โ switch โ false โ List the specified directory itself instead of its contents โ
โ 8 โ --mime-type(-m) โ switch โ false โ Show mime-type in type column instead of 'file' (based on filenames โ
โ โ โ โ โ only; files' contents are not examined) โ
โ 9 โ --threads(-t) โ switch โ false โ Use multiple threads to list contents. Output will be โ
โ โ โ โ โ non-deterministic. โ
โฐโโโโดโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
The commands below are equivalent and will produce the same output mentioned previously. It's worth mentioning these alternatives to improve understanding of how to access data differently in Nushell. It would be like navigating inside the object in the params session (object.params).
help commands | where name == ls | first | get params
#object.params
(help commands | where name == ls | first).params
If yaml is structured data, let's test Nushell's power with a simple kubernetes deployment manifest that we'll create now.
# Command used to create a deployment file in kubernetes which is a yaml structure.
kubectl create deployment nginx --image nginx --dry-run=client -oyaml > deploy.yaml
# We have here our deployment manifest.
~> cat deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
resources: {}
status: {}
# And how do we see this deployment structure in Nushell?
# How does it understand this? See that it interprets the data and creates the structure for us.
~> open deploy.yaml
โญโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ apiVersion โ apps/v1 โ
โ kind โ Deployment โ
โ โ โญโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฎ โ
โ metadata โ โ creationTimestamp โ โ โ
โ โ โ โ โญโโโโโโฌโโโโโโโโฎ โ โ
โ โ โ labels โ โ app โ nginx โ โ โ
โ โ โ โ โฐโโโโโโดโโโโโโโโฏ โ โ
โ โ โ name โ nginx โ โ
โ โ โฐโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโฏ โ
โ โ โญโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ spec โ โ replicas โ 1 โ โ
โ โ โ โ โญโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฎ โ โ
โ โ โ selector โ โ โ โญโโโโโโฌโโโโโโโโฎ โ โ โ
โ โ โ โ โ matchLabels โ โ app โ nginx โ โ โ โ
โ โ โ โ โ โ โฐโโโโโโดโโโโโโโโฏ โ โ โ
โ โ โ โ โฐโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโฏ โ โ
โ โ โ strategy โ {record 0 fields} โ โ
โ โ โ โ โญโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ โ
โ โ โ template โ โ โ โญโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฎ โ โ โ
โ โ โ โ โ metadata โ โ creationTimestamp โ โ โ โ โ
โ โ โ โ โ โ โ โ โญโโโโโโฌโโโโโโโโฎ โ โ โ โ
โ โ โ โ โ โ โ labels โ โ app โ nginx โ โ โ โ โ
โ โ โ โ โ โ โ โ โฐโโโโโโดโโโโโโโโฏ โ โ โ โ
โ โ โ โ โ โ โฐโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโฏ โ โ โ
โ โ โ โ โ โ โญโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ โ โ
โ โ โ โ โ spec โ โ โ โญโโโโฌโโโโโโโโฌโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโฎ โ โ โ โ
โ โ โ โ โ โ โ containers โ โ # โ image โ name โ resources โ โ โ โ โ
โ โ โ โ โ โ โ โ โโโโโผโโโโโโโโผโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค โ โ โ โ
โ โ โ โ โ โ โ โ โ 0 โ nginx โ nginx โ {record 0 fields} โ โ โ โ โ
โ โ โ โ โ โ โ โ โฐโโโโดโโโโโโโโดโโโโโโโโดโโโโโโโโโโโโโโโโโโโโฏ โ โ โ โ
โ โ โ โ โ โ โฐโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ โ โ
โ โ โ โ โฐโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ โ
โ โ โฐโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ status โ {record 0 fields} โ
โฐโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
## And we can extract whatever we want just by looking at the structure above.
~> open deploy.yaml | get spec.template.spec.containers
โญโโโโฌโโโโโโโโฌโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโฎ
โ # โ image โ name โ resources โ
โโโโโผโโโโโโโโผโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ 0 โ nginx โ nginx โ {record 0 fields} โ
โฐโโโโดโโโโโโโโดโโโโโโโโดโโโโโโโโโโโโโโโโโโโโฏ
~> open deploy.yaml | get spec.template.spec.containers | first
โญโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโฎ
โ image โ nginx โ
โ name โ nginx โ
โ resources โ {record 0 fields} โ
โฐโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโฏ
If you work with YAML and JSON, you know that using Jsonpath, although effective, can be laborious. Tools like jq and yq already simplify this process, but with Nushell, you'll discover an even more intuitive and efficient approach to manipulating structured data.
Helpโ
To find the help for each of these commands just type help command_name.
> help explore
Explore acts as a table pager, just like `less` does for text.
Press `:` then `h` to get a help menu.
Usage:
> explore {flags}
Flags:
-h, --help: Display the help message for this command
--head <bool>: Show or hide column headers (default true)
-i, --index: Show row indexes when viewing a list
-t, --tail: Start with the viewport scrolled to the bottom
-p, --peek: When quitting, output the value of the cell the cursor was on
Input/output types:
โญโโโโฌโโโโโโโโฌโโโโโโโโโฎ
โ # โ input โ output โ
โโโโโผโโโโโโโโผโโโโโโโโโค
โ 0 โ any โ any โ
โฐโโโโดโโโโโโโโดโโโโโโโโโฏ
Examples:
Explore the system host information record
> sys host | explore
Explore the output of `ls` without column names
> ls | explore --head false
Explore a list of Markdown files' contents, with row indexes
> glob *.md | each {|| open } | explore --index
Explore a JSON file, then save the last visited sub-structure to a file
> open file.json | explore --peek | to json | save part.json
For example the explore command helps us navigate in generated data.

If we can use the explorer to navigate in structured data then we can do this help commands | explore to have interactivity in searching for what we want.
A detail is that the help command has these possible inputs.
> help
help Display help information about different parts of Nushell.
help aliases Show help on nushell aliases.
help commands Show help on nushell commands.
help escapes Show help on nushell string escapes.
help externs Show help on nushell externs.
help modules Show help on nushell modules.
help operators Show help on nushell operators.
For example a history command how to use?
> help history
Get the command history.
Usage:
> history {flags}
Subcommands:
history import - Import command line history
history session - Get the command history session.
Flags:
-h, --help: Display the help message for this command
-c, --clear: Clears out the history entries
-l, --long: Show long listing of entries for sqlite history
Input/output types:
โญโโโโฌโโโโโโโโโโฌโโโโโโโโโฎ
โ # โ input โ output โ
โโโโโผโโโโโโโโโโผโโโโโโโโโค
โ 0 โ nothing โ any โ
โฐโโโโดโโโโโโโโโโดโโโโโโโโโฏ
Examples:
Get current history length
> history | length
Show last 5 commands you have ran
> history | last 5
Search all the commands from history that contains 'cargo'
> history | where command =~ cargo | get command
# If history will give us the command column then let's filter in it
history | where command =~ "kubectl describe pod"
โญโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ # โ command โ
โโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 282 โ kubectl describe pods -n kube-system kube-scheduler-kind-control-plane โ
โ 283 โ kubectl describe pods -n kube-system kube-scheduler-kind-control-plane โ
โ โ | detect
โฐโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# Now the first column is command... so let's get it
history | where command =~ "kubectl describe pod" | get command
โญโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ 0 โ kubectl describe pods -n kube-system kube-scheduler-kind-control-plane โ
โ 1 โ kubectl describe pods -n kube-system kube-scheduler-kind-control-plane โ
โ โ | detect
โฐโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ