···6565 | S_DIR -> completions path None
6666 | _ -> [])
67676868+ (* For now a very simple, prefixed based history *)
6969+7070+ let h = ref []
7171+7272+ let history prefix =
7373+ if prefix <> "" then List.filter (fun s -> String.starts_with ~prefix s) !h
7474+ else !h
7575+6876 let run ?(prompt = default_prompt) initial_ctx =
6977 Sys.set_signal Sys.sigttou Sys.Signal_ignore;
7078 Sys.set_signal Sys.sigttin Sys.Signal_ignore;
···7583 |> Option.map Ast.word_components_to_string);
7684 let p = prompt ctx in
7785 Fmt.pr "%s\r%!" p;
7878- match Bruit.bruit ~complete "" with
8686+ match Bruit.bruit ~history ~complete "" with
7987 | String None ->
8088 Fmt.pr "exit\n%!";
8189 exit 0
8290 | String (Some c) ->
8383- (* Fmt.epr ">>> [%s]\n%!" c; *)
8491 let ast = Ast.of_string (String.trim c) in
8592 let ctx', _ast = Eval.run ctx ast in
8686- (* TODO: Make better History abstraction *)
8787- (* let _ : (unit, string) result = LNoise.history_add c in *)
9393+ h := c :: !h;
8894 loop ctx'
8995 | Ctrl_c ->
9096 let c = Exit.value ctx in