Home Explore Blog CI



nushell

1st chunk of `book/coloring_and_theming.md`
8e35ff3c0ebe11be7f6349d67c859472a54cb08dd3b67fb50000000100001019
# Coloring and Theming in Nu

Many parts of Nushell's interface can have their color customized. All of these can be set in the `config.nu` configuration file. If you see the `#` outside of a text value in the config file it means the text after it is commented out.

## Table Borders

Table borders are controlled by the `$env.config.table.mode` setting. It can be changed at run time, or in the `config.nu` file:

```nu
$env.config.table.mode = 'rounded'
```

The options for `$env.config.table.mode` can be listed with `table --list`:

<!-- Generated with table --list | each {|| $"- `($in)`"} | sort | str join "\n"` -->

- `ascii_rounded`
- `basic_compact`
- `basic`
- `compact_double`
- `compact`
- `default`
- `dots`
- `heavy`
- `light`
- `markdown`
- `none`
- `psql`
- `reinforced`
- `restructured`
- `rounded`
- `thin`
- `with_love`

Examples:

```nu
$env.config.table.mode = 'rounded'
table --list | first 5
# => ╭───┬────────────────╮
# => │ 0 │ basic          │
# => │ 1 │ compact        │
# => │ 2 │ compact_double │
# => │ 3 │ default        │
# => │ 4 │ heavy          │
# => ╰───┴────────────────╯

$env.config.table.mode = 'psql'
table --list | first 5
# =>  0 | basic
# =>  1 | compact
# =>  2 | compact_double
# =>  3 | default
# =>  4 | heavy
```

## Color Configuration

The color configuration is defined in `$env.config.color_config`. The current configuration can be printed with:

```nu
$env.config.color_config | sort
```

The color and style-attributes can be declared in multiple alternative formats.

- `r` - normal color red's abbreviation
- `rb` - normal color red's abbreviation with bold attribute
- `red` - normal color red
- `red_bold` - normal color red with bold attribute
- `"#ff0000"` - "#hex" format foreground color red (quotes are required)
- `{ fg: "#ff0000" bg: "#0000ff" attr: b }` - "full #hex" format foreground red in "#hex" format with a background of blue in "#hex" format with an attribute of bold abbreviated.
- `{|x| 'yellow' }` - closure returning a string with one of the color representations listed above
- `{|x| { fg: "#ff0000" bg: "#0000ff" attr: b } }` - closure returning a valid record

### Attributes

| code | meaning             |
| ---- | ------------------- |
| l    | blink               |
| b    | bold                |
| d    | dimmed              |
| h    | hidden              |
| i    | italic              |
| r    | reverse             |
| s    | strikethrough       |
| u    | underline           |
| n    | nothing             |
|      | defaults to nothing |

### Normal Colors and Abbreviations

| code      | name                      |
| --------- | ------------------------- |
| `g`       | `green`                   |
| `gb`      | `green_bold`              |
| `gu`      | `green_underline`         |
| `gi`      | `green_italic`            |
| `gd`      | `green_dimmed`            |
| `gr`      | `green_reverse`           |
| `bg_g`    | `bg_green`                |
| `lg`      | `light_green`             |
| `lgb`     | `light_green_bold`        |
| `lgu`     | `light_green_underline`   |
| `lgi`     | `light_green_italic`      |
| `lgd`     | `light_green_dimmed`      |
| `lgr`     | `light_green_reverse`     |
| `bg_lg`   | `bg_light_green`          |
| `r`       | `red`                     |
| `rb`      | `red_bold`                |
| `ru`      | `red_underline`           |
| `ri`      | `red_italic`              |
| `rd`      | `red_dimmed`              |
| `rr`      | `red_reverse`             |
| `bg_r`    | `bg_red`                  |
| `lr`      | `light_red`               |
| `lrb`     | `light_red_bold`          |
| `lru`     | `light_red_underline`     |
| `lri`     | `light_red_italic`        |
| `lrd`     | `light_red_dimmed`        |
| `lrr`     | `light_red_reverse`       |
| `bg_lr`   | `bg_light_red`            |
| `u`       | `blue`                    |
| `ub`      | `blue_bold`               |
| `uu`      | `blue_underline`          |
| `ui`      | `blue_italic`             |

Title: Coloring and Theming in Nu
Summary
This section describes how to customize the color and theme of Nushell's interface using the `config.nu` file. It covers how to set the table border style using `$env.config.table.mode` and provides a list of available table modes. It also explains how to configure colors using `$env.config.color_config`, detailing the different formats for declaring color and style attributes, including abbreviations, hex codes, and closures. It includes tables that list available attributes, normal colors, and their abbreviations.