Nushell Niceties: Tables With Different Themes
A lot of commands have output displayed as table. It is possible to use different themes for tables. If you run the command table --list you get all available themes. At the moment the following themes are available: basic, compact, compact_double, default, heavy, light, none, reinforced, rounded, thin, with_love, psql, markdown, dots, restructured, ascii_rounded, basic_compact, single, double. You can use a theme with the table command by using the --theme option and the name of the theme. For example to have a different table theme for the ls command you can use ls | table --theme light.
If you want to change the theme for all table output you can set the configuration option $env.config.table.mode. To make this configuration setting permanent you can add it to config.nu file.
In the following examples all different themes and how they look are shown:
> [[a b]; [1 2] [3 4]] | table --theme basic --index false
+---+---+
| a | b |
+---+---+
| 1 | 2 |
+---+---+
| 3 | 4 |
+---+---+
> [[a b]; [1 2] [3 4]] | table --theme compact --index false
───┬───
a │ b
───┼───
1 │ 2
3 │ 4
───┴───
> [[a b]; [1 2] [3 4]] | table --theme compact_double --index false
═══╦═══
a ║ b
═══╬═══
1 ║ 2
3 ║ 4
═══╩═══
> [[a b]; [1 2] [3 4]] | table --theme default --index false
╭───┬───╮
│ a │ b │
├───┼───┤
│ 1 │ 2 │
│ 3 │ 4 │
╰───┴───╯
> [[a b]; [1 2] [3 4]] | table --theme heavy --index false
┏━━━┳━━━┓
┃ a ┃ b ┃
┣━━━╋━━━┫
┃ 1 ┃ 2 ┃
┃ 3 ┃ 4 ┃
┗━━━┻━━━┛
> [[a b]; [1 2] [3 4]] | table --theme light --index false
a b
───────
1 2
3 4
> [[a b]; [1 2] [3 4]] | table --theme none --index false
a b
1 2
3 4
> [[a b]; [1 2] [3 4]] | table --theme reinforced --index false
┏───┬───┓
│ a │ b │
│ 1 │ 2 │
│ 3 │ 4 │
┗───┴───┛
> [[a b]; [1 2] [3 4]] | table --theme rounded --index false
╭───┬───╮
│ a │ b │
├───┼───┤
│ 1 │ 2 │
│ 3 │ 4 │
╰───┴───╯
> [[a b]; [1 2] [3 4]] | table --theme thin --index false
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 2 │
├───┼───┤
│ 3 │ 4 │
└───┴───┘
> [[a b]; [1 2] [3 4]] | table --theme with_love --index false
❤❤❤❤❤❤❤
a ❤ b
❤❤❤❤❤❤❤
1 ❤ 2
3 ❤ 4
❤❤❤❤❤❤❤
> [[a b]; [1 2] [3 4]] | table --theme psql --index false
a | b
---+---
1 | 2
3 | 4
> [[a b]; [1 2] [3 4]] | table --theme markdown --index false
| a | b |
|---|---|
| 1 | 2 |
| 3 | 4 |
> [[a b]; [1 2] [3 4]] | table --theme dots --index false
.........
: a : b :
: 1 : 2 :
: 3 : 4 :
:...:...:
> [[a b]; [1 2] [3 4]] | table --theme restructured --index false
=== ===
a b
=== ===
1 2
3 4
=== ===
> [[a b]; [1 2] [3 4]] | table --theme ascii_rounded --index false
.-------.
| a | b |
| 1 | 2 |
| 3 | 4 |
'-------'
> [[a b]; [1 2] [3 4]] | table --theme basic_compact --index false
+---+---+
| a | b |
| 1 | 2 |
| 3 | 4 |
+---+---+
> [[a b]; [1 2] [3 4]] | table --theme single --index false
┌───┬───┐
│ a │ b │
├───┼───┤
│ 1 │ 2 │
│ 3 │ 4 │
└───┴───┘
> [[a b]; [1 2] [3 4]] | table --theme double --index false
╔═══╦═══╗
║ a ║ b ║
╠═══╬═══╣
║ 1 ║ 2 ║
║ 3 ║ 4 ║
╚═══╩═══╝
Written with Nushell 0.108.0.