diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-04-25T14·57+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-04-25T14·57+0200 |
commit | fee93541a441b35cb62b11dd1c2c787a5df63b15 (patch) | |
tree | 76c8a3736c1b521c1a9e7920b1742981cb07ad81 | |
parent | 2dff9556a4131af8a50647f23fe03bfc3c295e12 (diff) | |
parent | 103c46abc273266afcd5dbffa40151114234a02b (diff) |
Merge branch 'master' of https://github.com/olejorgenb/nix-repl
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | nix-repl.cc | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/README.md b/README.md index 57613cc19e98..ac5ad98cf53c 100644 --- a/README.md +++ b/README.md @@ -102,3 +102,7 @@ example: nix-repl> config.networking.use<TAB> config.networking.useDHCP config.networking.usePredictableInterfaceNames + +Input history is preserved by readline in ~/.nix-repl-history +The readline "application name" is nix-repl. This allows for nix-repl specific +settings in ~/.inputrc diff --git a/nix-repl.cc b/nix-repl.cc index 0c50f4683300..71790eb481a7 100644 --- a/nix-repl.cc +++ b/nix-repl.cc @@ -29,6 +29,9 @@ using namespace nix; #define ESC_CYA "\033[36m" #define ESC_END "\033[0m" +string programId = "nix-repl"; +const string historyFile = string(getenv("HOME")) + "/.nix-repl-history"; + struct NixRepl { string curDir; @@ -127,8 +130,10 @@ void NixRepl::mainLoop(const Strings & files) reloadFiles(); if (!loadedFiles.empty()) std::cout << std::endl; + // Allow nix-repl specific settings in .inputrc + rl_readline_name = "nix-repl"; using_history(); - read_history(0); + read_history(historyFile.c_str()); string input; @@ -708,5 +713,7 @@ int main(int argc, char * * argv) NixRepl repl(searchPath, openStore()); repl.mainLoop(files); + + write_history(historyFile.c_str()); }); } |