mirror of
https://github.com/nushell/nushell.git
synced 2025-01-03 04:50:28 +01:00
Add --short banner option
This commit is contained in:
parent
f2e8c391a2
commit
929515e39b
@ -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);
|
||||
|
@ -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<String, Value>,
|
||||
@ -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(),
|
||||
|
@ -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 }
|
||||
|
Loading…
Reference in New Issue
Block a user