mirror of
https://github.com/nushell/nushell.git
synced 2024-12-22 23:23:12 +01:00
add configuration of maximum history size (#563)
This commit is contained in:
parent
5c83f4d405
commit
ba1ff4cf6c
@ -52,6 +52,7 @@ pub struct Config {
|
|||||||
pub use_ansi_coloring: bool,
|
pub use_ansi_coloring: bool,
|
||||||
pub env_conversions: HashMap<String, EnvConversion>,
|
pub env_conversions: HashMap<String, EnvConversion>,
|
||||||
pub edit_mode: String,
|
pub edit_mode: String,
|
||||||
|
pub max_history_size: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
@ -69,6 +70,7 @@ impl Default for Config {
|
|||||||
use_ansi_coloring: true,
|
use_ansi_coloring: true,
|
||||||
env_conversions: HashMap::new(), // TODO: Add default conversoins
|
env_conversions: HashMap::new(), // TODO: Add default conversoins
|
||||||
edit_mode: "emacs".into(),
|
edit_mode: "emacs".into(),
|
||||||
|
max_history_size: 1000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,6 +183,9 @@ impl Value {
|
|||||||
"edit_mode" => {
|
"edit_mode" => {
|
||||||
config.edit_mode = value.as_string()?;
|
config.edit_mode = value.as_string()?;
|
||||||
}
|
}
|
||||||
|
"max_history_size" => {
|
||||||
|
config.max_history_size = value.as_i64()?;
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,10 @@ fn main() -> Result<()> {
|
|||||||
),
|
),
|
||||||
))
|
))
|
||||||
.with_history(Box::new(
|
.with_history(Box::new(
|
||||||
FileBackedHistory::with_file(1000, history_path.clone())
|
FileBackedHistory::with_file(
|
||||||
|
config.max_history_size as usize,
|
||||||
|
history_path.clone(),
|
||||||
|
)
|
||||||
.into_diagnostic()?,
|
.into_diagnostic()?,
|
||||||
))
|
))
|
||||||
.into_diagnostic()?
|
.into_diagnostic()?
|
||||||
|
Loading…
Reference in New Issue
Block a user