diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index 4bd86ddbf9..505a1b47c1 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -146,15 +146,30 @@ pub fn evaluate_repl( // Regenerate the $nu constant to contain the startup time and any other potential updates engine_state.generate_nu_constant(); - if load_std_lib.is_none() && engine_state.get_config().show_banner { - eval_source( - engine_state, - &mut unique_stack, - r#"banner"#.as_bytes(), - "show_banner", - PipelineData::empty(), - false, - ); + if load_std_lib.is_none() { + match engine_state.get_config().show_banner { + Value::Bool { val: false, ..} => {} + Value::String { ref val, ..} if val == "short" => { + eval_source( + engine_state, + &mut unique_stack, + r#"banner --short"#.as_bytes(), + "show short banner", + PipelineData::empty(), + false, + ); + } + _ => { + eval_source( + engine_state, + &mut unique_stack, + r#"banner"#.as_bytes(), + "show_banner", + PipelineData::empty(), + false, + ); + } + } } kitty_protocol_healthcheck(engine_state); diff --git a/crates/nu-protocol/src/config/mod.rs b/crates/nu-protocol/src/config/mod.rs index 85ae9ce1e3..d2ee40a2a0 100644 --- a/crates/nu-protocol/src/config/mod.rs +++ b/crates/nu-protocol/src/config/mod.rs @@ -59,7 +59,7 @@ pub struct Config { pub rm: RmConfig, pub shell_integration: ShellIntegrationConfig, pub buffer_editor: Value, - pub show_banner: bool, + pub show_banner: Value, pub bracketed_paste: bool, pub render_right_prompt_on_last_line: bool, pub explore: HashMap, @@ -82,7 +82,7 @@ pub struct Config { impl Default for Config { fn default() -> Config { Config { - show_banner: true, + show_banner: Value::bool(true, Span::unknown()), table: TableConfig::default(), rm: RmConfig::default(), diff --git a/crates/nu-std/std/core/mod.nu b/crates/nu-std/std/core/mod.nu index 3a010c1fb3..37f10f243b 100644 --- a/crates/nu-std/std/core/mod.nu +++ b/crates/nu-std/std/core/mod.nu @@ -1,11 +1,18 @@ use std/dt [datetime-diff, pretty-print-duration] # Print a banner for nushell with information about the project -export def banner [] { +export def banner [ + --short # Only show startup time +] { let dt = (datetime-diff (date now) 2019-05-10T09:59:12-07:00) let ver = (version) -let banner_msg = $"(ansi green) __ ,(ansi reset) +let startup_time = $"('Startup Time: ' | ansi gradient --fgstart '0x20a000' --fgend '0x20ff00')($nu.startup-time)" + +let banner_msg = match $short { + true => $"($startup_time)(char newline)" + + false => $"(ansi green) __ ,(ansi reset) (ansi green) .--\(\)°'.' (ansi reset)Welcome to (ansi green)Nushell(ansi reset), (ansi green)'|, . ,' (ansi reset)based on the (ansi green)nu(ansi reset) language, (ansi green) !_-\(_\\ (ansi reset)where all data is structured! @@ -20,8 +27,9 @@ Learn how to remove this at: (ansi green)https://nushell.sh/book/configuration.h It's been this long since (ansi green)Nushell(ansi reset)'s first commit: (pretty-print-duration $dt) -Startup Time: ($nu.startup-time) +($startup_time) " +} match $env.config?.use_ansi_coloring? { false => { $banner_msg | ansi strip }