diff --git a/README.md b/README.md index 222f401..2ed5a47 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,7 @@ $ hyaml True >>> ``` +Your command history is stored in the `~/.hyaml_history` file. ## ANTLR diff --git a/hyaml/__init__.py b/hyaml/__init__.py index 86e1abe..f0dca10 100644 --- a/hyaml/__init__.py +++ b/hyaml/__init__.py @@ -1,4 +1,6 @@ def main(): + import os + import readline from hyaml.translator import translate from hyaml.compiler import compile_expression from code import interact @@ -7,4 +9,12 @@ def evaluate(expr, **lcls): fn = compile_expression(expr, bindings=("variables",)) return fn(variables=lcls) - interact(local={"evaluate": evaluate, "translate": translate}) + histfile = os.path.join(os.path.expanduser("~"), ".hyaml_history") + try: + readline.read_history_file(histfile) + except FileNotFoundError: + pass + + interact(banner="HYAML Playgroud", local={"evaluate": evaluate, "translate": translate}) + + readline.write_history_file(histfile)