mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
create history file if it doesnt exit (#605)
This commit is contained in:
parent
53330c5676
commit
5c94528fe2
16
src/main.rs
16
src/main.rs
@ -295,14 +295,20 @@ fn main() -> Result<()> {
|
||||
report_error(&working_set, &e);
|
||||
}
|
||||
|
||||
let history_path = if let Some(mut history_path) = nu_path::config_dir() {
|
||||
let history_path = nu_path::config_dir().and_then(|mut history_path| {
|
||||
history_path.push("nushell");
|
||||
history_path.push("history.txt");
|
||||
|
||||
Some(history_path)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if !history_path.exists() {
|
||||
// Creating an empty file to store the history
|
||||
match std::fs::File::create(&history_path) {
|
||||
Ok(_) => Some(history_path),
|
||||
Err(_) => None,
|
||||
}
|
||||
} else {
|
||||
Some(history_path)
|
||||
}
|
||||
});
|
||||
|
||||
#[cfg(feature = "plugin")]
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user