diff --git a/crates/nu-protocol/src/config.rs b/crates/nu-protocol/src/config.rs index 4d5024a200..fe94a33920 100644 --- a/crates/nu-protocol/src/config.rs +++ b/crates/nu-protocol/src/config.rs @@ -2,6 +2,8 @@ use crate::{ShellError, Value}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; +const ANIMATE_PROMPT_DEFAULT: bool = true; + #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Config { pub filesize_metric: bool, @@ -10,6 +12,7 @@ pub struct Config { pub color_config: HashMap, pub use_grid_icons: bool, pub footer_mode: FooterMode, + pub animate_prompt: bool, } impl Default for Config { @@ -21,6 +24,7 @@ impl Default for Config { color_config: HashMap::new(), use_grid_icons: false, footer_mode: FooterMode::Never, + animate_prompt: ANIMATE_PROMPT_DEFAULT, } } } @@ -77,6 +81,11 @@ impl Value { }, }; } + "animate_prompt" => { + let val = value.as_bool()?; + + config.animate_prompt = val; + } _ => {} } } diff --git a/src/main.rs b/src/main.rs index 666f516be8..9a84cf6923 100644 --- a/src/main.rs +++ b/src/main.rs @@ -230,20 +230,11 @@ fn main() -> Result<()> { } loop { + let config = stack.get_config()?; + //Reset the ctrl-c handler ctrlc.store(false, Ordering::SeqCst); - const EQ_PROMPT_ANIMATE_DEFAULT: bool = true; - // Toggle prompt animation - let animate = match std::env::var("EQ_PROMPT_ANIMATE") { - Ok(ms_str) => match ms_str.as_str() { - "ON" | "1" => true, - "OFF" | "0" => false, - _ => EQ_PROMPT_ANIMATE_DEFAULT, - }, - _ => EQ_PROMPT_ANIMATE_DEFAULT, - }; - let line_editor = Reedline::create() .into_diagnostic()? .with_completion_action_handler(Box::new(FuzzyCompletion { @@ -252,7 +243,7 @@ fn main() -> Result<()> { .with_highlighter(Box::new(NuHighlighter { engine_state: engine_state.clone(), })) - .with_animation(animate) + .with_animation(config.animate_prompt) // .with_completion_action_handler(Box::new( // ListCompletionHandler::default().with_completer(Box::new(completer)), // ))