Make the history path more central

This commit is contained in:
JT 2021-10-28 13:30:58 +13:00
parent 1eb93e5c07
commit f92e9d25a5
2 changed files with 34 additions and 12 deletions

14
TODO.md
View file

@ -31,13 +31,19 @@
- [x] finish operator type-checking
- [x] Config file loading
- [x] block variable captures
- [ ] Input/output types
- [x] improved history and config paths
- [ ] Support for `$in`
- [ ] ctrl-c support
- [ ] operator overflow
- [ ] Overlays (replacement for `autoenv`)
- [ ] shells
- [ ] plugins
- [ ] dataframes
## Post-nushell merge:
- [ ] Overlays (replacement for `autoenv`), adding modules to shells
- [ ] Input/output types
- [ ] let [first, rest] = [1, 2, 3] (design question: how do you pattern match a table?)
## Maybe:
- [ ] default param values?
- [ ] Unary not?
- [ ] let [first, rest] = [1, 2, 3] (design question: how do you pattern match a table?)

View file

@ -143,19 +143,24 @@ fn main() -> Result<()> {
}
}
let history_path = if let Some(mut history_path) = nu_path::config_dir() {
history_path.push("nushell");
history_path.push("history.txt");
Some(history_path)
} else {
None
};
loop {
let mut line_editor = Reedline::create()
let line_editor = Reedline::create()
.into_diagnostic()?
.with_history(Box::new(
FileBackedHistory::with_file(1000, "history.txt".into()).into_diagnostic()?,
))
.into_diagnostic()?
.with_highlighter(Box::new(NuHighlighter {
engine_state: engine_state.clone(),
}))
.with_completion_action_handler(Box::new(FuzzyCompletion {
completer: Box::new(completer.clone()),
}))
.with_highlighter(Box::new(NuHighlighter {
engine_state: engine_state.clone(),
}))
// .with_completion_action_handler(Box::new(
// ListCompletionHandler::default().with_completer(Box::new(completer)),
// ))
@ -163,6 +168,17 @@ fn main() -> Result<()> {
engine_state: engine_state.clone(),
}));
let mut line_editor = if let Some(history_path) = history_path.clone() {
line_editor
.with_history(Box::new(
FileBackedHistory::with_file(1000, history_path.clone())
.into_diagnostic()?,
))
.into_diagnostic()?
} else {
line_editor
};
let prompt = update_prompt(
PROMPT_COMMAND,
&engine_state,