Skip to content

Commit 1c88467

Browse files
committed
book: fix suggested configuration syntax to merge rather than override
1 parent abd985a commit 1c88467

File tree

2 files changed

+61
-77
lines changed

2 files changed

+61
-77
lines changed

book/coloring_and_theming.md

Lines changed: 58 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -322,47 +322,39 @@ This is the current list of primitives. Not all of these are configurable. The c
322322
Here's a small example of changing some of these values.
323323

324324
```nu
325-
let config = {
326-
color_config: {
327-
separator: purple
328-
leading_trailing_space_bg: "#ffffff"
329-
header: gb
330-
date: wd
331-
filesize: c
332-
row_index: cb
333-
bool: red
334-
int: green
335-
duration: blue_bold
336-
range: purple
337-
float: red
338-
string: white
339-
nothing: red
340-
binary: red
341-
cellpath: cyan
342-
hints: dark_gray
343-
}
344-
}
325+
$env.config.color_config.separator = purple
326+
$env.config.color_config.leading_trailing_space_bg = "#ffffff"
327+
$env.config.color_config.header = gb
328+
$env.config.color_config.date = wd
329+
$env.config.color_config.filesize = c
330+
$env.config.color_config.row_index = cb
331+
$env.config.color_config.bool = red
332+
$env.config.color_config.int = green
333+
$env.config.color_config.duration = blue_bold
334+
$env.config.color_config.range = purple
335+
$env.config.color_config.float = red
336+
$env.config.color_config.string = white
337+
$env.config.color_config.nothing = red
338+
$env.config.color_config.binary = red
339+
$env.config.color_config.cellpath = cyan
340+
$env.config.color_config.hints = dark_gray
345341
```
346342

347343
Here's another small example using multiple color syntaxes with some comments.
348344

349345
```nu
350-
let config = {
351-
color_config: {
352-
separator: "#88b719" # this sets only the foreground color like PR #486
353-
leading_trailing_space_bg: white # this sets only the foreground color in the original style
354-
header: { # this is like PR #489
355-
fg: "#B01455", # note, quotes are required on the values with hex colors
356-
bg: "#ffb900", # note, commas are not required, it could also be all on one line
357-
attr: bli # note, there are no quotes around this value. it works with or without quotes
358-
}
359-
date: "#75507B"
360-
filesize: "#729fcf"
361-
row_index: {
362-
# note, that this is another way to set only the foreground, no need to specify bg and attr
363-
fg: "#e50914"
364-
}
365-
}
346+
$env.config.color_config.separator = "#88b719" # this sets only the foreground color like PR #486
347+
$env.config.color_config.leading_trailing_space_bg = white # this sets only the foreground color in the original style
348+
$env.config.color_config.header = { # this is like PR #489
349+
fg: "#B01455", # note, quotes are required on the values with hex colors
350+
bg: "#ffb900", # note, commas are not required, it could also be all on one line
351+
attr: bli # note, there are no quotes around this value. it works with or without quotes
352+
}
353+
$env.config.color_config.date = "#75507B"
354+
$env.config.color_config.filesize = "#729fcf"
355+
$env.config.color_config.row_index = {
356+
# note, that this is another way to set only the foreground, no need to specify bg and attr
357+
fg: "#e50914"
366358
}
367359
```
368360

@@ -390,6 +382,7 @@ Here's the current list of flat shapes.
390382
| `shape_literal` | fg(Color::Blue) | \* |
391383
| `shape_nothing` | fg(Color::LightCyan) | \* |
392384
| `shape_operator` | fg(Color::Yellow) | \* |
385+
| `shape_pipe` | fg(Color::Purple).bold() | \* |
393386
| `shape_range` | fg(Color::Yellow).bold() | \* |
394387
| `shape_record` | fg(Color::Cyan).bold() | \* |
395388
| `shape_signature` | fg(Color::Green).bold() | \* |
@@ -398,16 +391,12 @@ Here's the current list of flat shapes.
398391
| `shape_table` | fg(Color::Blue).bold() | \* |
399392
| `shape_variable` | fg(Color::Purple) | \* |
400393

401-
Here's a small example of how to apply color to these items. Anything not specified will receive the default color.
394+
Here's a small example of how to apply color to these items. Anything not overidden will receive its default color.
402395

403396
```nu
404-
$env.config = {
405-
color_config: {
406-
shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b}
407-
shape_bool: green
408-
shape_int: { fg: "#0000ff" attr: b}
409-
}
410-
}
397+
$env.config.color_config.shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b}
398+
$env.config.color_config.shape_bool: green
399+
$env.config.color_config.shape_int: { fg: "#0000ff" attr: b}
411400
```
412401

413402
## Prompt Configuration and Coloring
@@ -437,10 +426,7 @@ $env.PROMPT_INDICATOR = "> "
437426
If you're using `starship`, you'll most likely want to show the right prompt on the last line of the prompt, just like zsh or fish. You could modify the `config.nu` file, just set `render_right_prompt_on_last_line` to true:
438427

439428
```nu
440-
config {
441-
render_right_prompt_on_last_line = true
442-
...
443-
}
429+
$env.config.render_right_prompt_on_last_line = true
444430
```
445431

446432
Coloring of the prompt is controlled by the `block` in `PROMPT_COMMAND` where you can write your own custom prompt. We've written a slightly fancy one that has git statuses located in the [nu_scripts repo](https://github.com/nushell/nu_scripts/blob/main/modules/prompt/oh-my.nu).
@@ -553,44 +539,42 @@ let base16_theme = {
553539
cellpath: $base08
554540
hints: dark_gray
555541
556-
# shape_garbage: { fg: $base07 bg: $base08 attr: b} # base16 white on red
542+
# shape_garbage: { fg: $base07 bg: $base08 attr: b } # base16 white on red
557543
# but i like the regular white on red for parse errors
558-
shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b}
544+
shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b }
559545
shape_bool: $base0d
560-
shape_int: { fg: $base0e attr: b}
561-
shape_float: { fg: $base0e attr: b}
562-
shape_range: { fg: $base0a attr: b}
563-
shape_internalcall: { fg: $base0c attr: b}
546+
shape_int: { fg: $base0e attr: b }
547+
shape_float: { fg: $base0e attr: b }
548+
shape_range: { fg: $base0a attr: b }
549+
shape_internalcall: { fg: $base0c attr: b }
564550
shape_external: $base0c
565-
shape_externalarg: { fg: $base0b attr: b}
551+
shape_externalarg: { fg: $base0b attr: b }
566552
shape_literal: $base0d
567553
shape_operator: $base0a
568-
shape_signature: { fg: $base0b attr: b}
554+
shape_signature: { fg: $base0b attr: b }
569555
shape_string: $base0b
570556
shape_filepath: $base0d
571-
shape_globpattern: { fg: $base0d attr: b}
557+
shape_globpattern: { fg: $base0d attr: b }
572558
shape_variable: $base0e
573-
shape_flag: { fg: $base0d attr: b}
574-
shape_custom: {attr: b}
559+
shape_flag: { fg: $base0d attr: b }
560+
shape_custom: { attr: b }
575561
}
576562
577563
# now let's apply our regular config settings but also apply the "color_config:" theme that we specified above.
578564
579-
let config = {
580-
filesize_metric: true
581-
table_mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
582-
use_ls_colors: true
583-
color_config: $base16_theme # <-- this is the theme
584-
use_grid_icons: true
585-
footer_mode: always #always, never, number_of_rows, auto
586-
animate_prompt: false
587-
float_precision: 2
588-
use_ansi_coloring: true
589-
filesize_format: "b" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto
590-
edit_mode: emacs # vi
591-
max_history_size: 10000
592-
log_level: error
593-
}
565+
$env.config.animate_prompt: false
566+
$env.config.color_config: $base16_theme # <-- this is the theme
567+
$env.config.edit_mode: emacs # vi
568+
$env.config.filesize_format: "b" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto
569+
$env.config.filesize_metric: true
570+
$env.config.float_precision: 2
571+
$env.config.footer_mode: always #always, never, number_of_rows, auto
572+
$env.config.log_level: error
573+
$env.config.max_history_size: 10000
574+
$env.config.table_mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
575+
$env.config.use_ansi_coloring: true
576+
$env.config.use_grid_icons: true
577+
$env.config.use_ls_colors: true
594578
```
595579

596580
if you want to go full-tilt on theming, you'll want to theme all the items I mentioned at the very beginning, including LS_COLORS, and the prompt. Good luck!

book/line_editor.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,9 @@ values, together with extra information that could be inserted into the buffer.
798798

799799
Let's say we want to create a menu that displays all the variables created
800800
during your session, we are going to call it `vars_menu`. This menu will use a
801-
list layout (layout: list). To search for values, we want to use only the things
802-
that are written after the menu has been activated (only_buffer_difference:
803-
true).
801+
list layout (`layout: list`). To search for values, we want to use only the things
802+
that are written after the menu has been activated
803+
(`only_buffer_difference: true`).
804804

805805
With that in mind, the desired menu would look like this
806806

0 commit comments

Comments
 (0)