Skip to content
This repository has been archived by the owner on Mar 27, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/olejorgenb/nix-repl
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Apr 25, 2017
2 parents 2dff955 + 103c46a commit fee9354
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion nix-repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -708,5 +713,7 @@ int main(int argc, char * * argv)

NixRepl repl(searchPath, openStore());
repl.mainLoop(files);

write_history(historyFile.c_str());
});
}

0 comments on commit fee9354

Please sign in to comment.