about summary refs log tree commit diff
path: root/nix-repl.cc
diff options
context:
space:
mode:
authorOle Jørgen Brønner <olejorgenb@yahoo.no>2016-02-23T22·19+0100
committerOle Jørgen Brønner <olejorgenb@yahoo.no>2016-02-23T22·19+0100
commit103c46abc273266afcd5dbffa40151114234a02b (patch)
tree47b18af162a3a29de61d69fca08c1cf942faf25a /nix-repl.cc
parent5599665a270128361862774701ae41fbfba5a661 (diff)
Preserve readline history across sessions. Add rl_readline_name.
Diffstat (limited to 'nix-repl.cc')
-rw-r--r--nix-repl.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/nix-repl.cc b/nix-repl.cc
index 577efa8e2ba5..1c878cd0e230 100644
--- a/nix-repl.cc
+++ b/nix-repl.cc
@@ -20,6 +20,7 @@ using namespace nix;
 
 
 string programId = "nix-repl";
+const string historyFile = string(getenv("HOME")) + "/.nix-repl-history";
 
 
 struct NixRepl
@@ -91,8 +92,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;
 
@@ -649,5 +652,7 @@ int main(int argc, char * * argv)
         store = openStore();
         NixRepl repl(searchPath);
         repl.mainLoop(files);
+
+        write_history(historyFile.c_str());
     });
 }