From 840b4b854b31e102cafd7667590626c4cfd0e19e Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Thu, 3 Aug 2023 08:06:51 +1200 Subject: [PATCH] Simplify default style and match Rust code to config (#9900) # Description This PR aligns the default config in the Rust code to the default config in the nushell file. To do so, it removes closures from the default file, opting instead to pick a simple style as default. This allows easier maintenance of both Rust and Nushell code without removing the ability to use closures for styling in your configuration. The default theme is now "dark mode" in both the Rust and nushell config code. Obligatory screenshot: ![image](https://github.com/nushell/nushell/assets/547158/233b11af-3b81-4513-8a69-3e7b1cac3865) # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-color-config/src/style_computer.rs | 10 ++-- .../src/sample_config/default_config.nu | 60 +++---------------- 2 files changed, 14 insertions(+), 56 deletions(-) diff --git a/crates/nu-color-config/src/style_computer.rs b/crates/nu-color-config/src/style_computer.rs index 25d578573..03ea07c07 100644 --- a/crates/nu-color-config/src/style_computer.rs +++ b/crates/nu-color-config/src/style_computer.rs @@ -143,13 +143,13 @@ impl<'a> StyleComputer<'a> { let mut map: StyleMapping = [ ("separator".to_string(), ComputableStyle::Static(Color::White.normal())), ("leading_trailing_space_bg".to_string(), ComputableStyle::Static(Style::default().on(Color::Rgb(128, 128, 128)))), - ("header".to_string(), ComputableStyle::Static(Color::White.normal())), - ("empty".to_string(), ComputableStyle::Static(Color::White.normal())), - ("bool".to_string(), ComputableStyle::Static(Color::White.normal())), + ("header".to_string(), ComputableStyle::Static(Color::Green.bold())), + ("empty".to_string(), ComputableStyle::Static(Color::Blue.normal())), + ("bool".to_string(), ComputableStyle::Static(Color::LightCyan.normal())), ("int".to_string(), ComputableStyle::Static(Color::White.normal())), - ("filesize".to_string(), ComputableStyle::Static(Color::White.normal())), + ("filesize".to_string(), ComputableStyle::Static(Color::Cyan.normal())), ("duration".to_string(), ComputableStyle::Static(Color::White.normal())), - ("date".to_string(), ComputableStyle::Static(Color::White.normal())), + ("date".to_string(), ComputableStyle::Static(Color::Purple.normal())), ("range".to_string(), ComputableStyle::Static(Color::White.normal())), ("float".to_string(), ComputableStyle::Static(Color::White.normal())), ("string".to_string(), ComputableStyle::Static(Color::White.normal())), diff --git a/crates/nu-utils/src/sample_config/default_config.nu b/crates/nu-utils/src/sample_config/default_config.nu index 6273358f6..101ce4728 100644 --- a/crates/nu-utils/src/sample_config/default_config.nu +++ b/crates/nu-utils/src/sample_config/default_config.nu @@ -14,33 +14,12 @@ let dark_theme = { empty: blue # Closures can be used to choose colors for specific values. # The value (in this case, a bool) is piped into the closure. - bool: {|| if $in { 'light_cyan' } else { 'light_gray' } } + # eg) {|| if $in { 'light_cyan' } else { 'light_gray' } } + bool: light_cyan int: white - filesize: {|e| - if $e == 0b { - 'white' - } else if $e < 1mb { - 'cyan' - } else { 'blue' } - } + filesize: cyan duration: white - date: {|| (date now) - $in | - if $in < 1hr { - 'purple' - } else if $in < 6hr { - 'red' - } else if $in < 1day { - 'yellow' - } else if $in < 3day { - 'green' - } else if $in < 1wk { - 'light_green' - } else if $in < 6wk { - 'cyan' - } else if $in < 52wk { - 'blue' - } else { 'dark_gray' } - } + date: purple range: white float: white string: white @@ -98,33 +77,12 @@ let light_theme = { empty: blue # Closures can be used to choose colors for specific values. # The value (in this case, a bool) is piped into the closure. - bool: {|| if $in { 'dark_cyan' } else { 'dark_gray' } } + # eg) {|| if $in { 'dark_cyan' } else { 'dark_gray' } } + bool: dark_cyan int: dark_gray - filesize: {|e| - if $e == 0b { - 'dark_gray' - } else if $e < 1mb { - 'cyan_bold' - } else { 'blue_bold' } - } + filesize: cyan_bold duration: dark_gray - date: {|| (date now) - $in | - if $in < 1hr { - 'purple' - } else if $in < 6hr { - 'red' - } else if $in < 1day { - 'yellow' - } else if $in < 3day { - 'green' - } else if $in < 1wk { - 'light_green' - } else if $in < 6wk { - 'cyan' - } else if $in < 52wk { - 'blue' - } else { 'dark_gray' } - } + date: purple range: dark_gray float: dark_gray string: dark_gray @@ -275,7 +233,7 @@ $env.config = { vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line (underscore is the default) } - color_config: {} # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record + color_config: $dark_theme # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record use_grid_icons: true footer_mode: "25" # always, never, number_of_rows, auto float_precision: 2 # the precision for displaying floats in tables