diff --git a/TODO.md b/TODO.md index 507079c9d7..b77f6b7a99 100644 --- a/TODO.md +++ b/TODO.md @@ -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?) diff --git a/src/main.rs b/src/main.rs index 02ded94a1c..22bb5de0c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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,