table
For viewers.
Render the table.
Command Type
built-in
Signature
> table {flags}
Flags
--theme, -t {string}: Set a table mode/theme.--index, -i {any}: Enable (true) or disable (false) the #/index column or set the starting index.--width, -w {int}: Number of terminal columns wide (not output columns).--expand, -e: Expand the table structure in a light mode.--expand-deep, -d {int}: An expand limit of recursion which will take place, must be used with —expand.--flatten: Flatten simple arrays.--flatten-separator {string}: Sets a separator when ‘flatten’ is used.--collapse, -c: Expand the table structure in collapse mode. Be aware collapse mode currently doesn’t support width control.--abbreviated, -a {int}: Abbreviate the data in the table by truncating the middle part and only showing amount provided on top and bottom.--list, -l: List available table modes/themes.--icons, -o: Add icons to file paths in tables.
Input/output types:
| input | output |
|---|---|
| any | any |
Examples
List the files in current directory, with indexes starting from 1
> ls | table --index 1
Render data in table view
> [[a b]; [1 2] [3 4]] | table
╭───┬───┬───╮
│ # │ a │ b │
├───┼───┼───┤
│ 0 │ 1 │ 2 │
│ 1 │ 3 │ 4 │
╰───┴───┴───╯
Render data in table view (expanded)
> [[a b]; [1 2] [3 [4 4]]] | table --expand
╭───┬───┬───────────╮
│ # │ a │ b │
├───┼───┼───────────┤
│ 0 │ 1 │ 2 │
│ 1 │ 3 │ ╭───┬───╮ │
│ │ │ │ 0 │ 4 │ │
│ │ │ │ 1 │ 4 │ │
│ │ │ ╰───┴───╯ │
╰───┴───┴───────────╯
Render data in table view (collapsed)
> [[a b]; [1 2] [3 [4 4]]] | table --collapse
╭───┬───┬───────────╮
│ # │ a │ b │
├───┼───┼───────────┤
│ 0 │ 1 │ 2 │
│ 1 │ 3 │ ╭───┬───╮ │
│ │ │ │ 0 │ 4 │ │
│ │ │ │ 1 │ 4 │ │
│ │ │ ╰───┴───╯ │
╰───┴───┴───────────╯
Change the table theme to the specified theme for a single run
> [[a b]; [1 2] [3 [4 4]]] | table --theme basic
Force showing of the #/index column for a single run
> [[a b]; [1 2] [3 [4 4]]] | table -i true
Set the starting number of the #/index column to 100 for a single run
> [[a b]; [1 2] [3 [4 4]]] | table -i 100
Force hiding of the #/index column for a single run
> [[a b]; [1 2] [3 [4 4]]] | table -i false
Notes
If the table contains a column called ‘index’, this column is used as the table index instead of the usual continuous index.
Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.