This commit is contained in:
Eelco Dolstra 2017-04-25 16:57:07 +02:00
commit fee93541a4
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 12 additions and 1 deletions

View file

@ -102,3 +102,7 @@ example:
nix-repl> config.networking.use<TAB> nix-repl> config.networking.use<TAB>
config.networking.useDHCP config.networking.usePredictableInterfaceNames 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

View file

@ -29,6 +29,9 @@ using namespace nix;
#define ESC_CYA "\033[36m" #define ESC_CYA "\033[36m"
#define ESC_END "\033[0m" #define ESC_END "\033[0m"
string programId = "nix-repl";
const string historyFile = string(getenv("HOME")) + "/.nix-repl-history";
struct NixRepl struct NixRepl
{ {
string curDir; string curDir;
@ -127,8 +130,10 @@ void NixRepl::mainLoop(const Strings & files)
reloadFiles(); reloadFiles();
if (!loadedFiles.empty()) std::cout << std::endl; if (!loadedFiles.empty()) std::cout << std::endl;
// Allow nix-repl specific settings in .inputrc
rl_readline_name = "nix-repl";
using_history(); using_history();
read_history(0); read_history(historyFile.c_str());
string input; string input;
@ -708,5 +713,7 @@ int main(int argc, char * * argv)
NixRepl repl(searchPath, openStore()); NixRepl repl(searchPath, openStore());
repl.mainLoop(files); repl.mainLoop(files);
write_history(historyFile.c_str());
}); });
} }