Am I missing some kind of readline facility in my setup?

I am trying out a small app using Plug, using the code from this question - Simple Elixir web page - use Phoenix or not?, which is based on the Plug docs - https://hexdocs.pm/plug/readme.html#the-plug-conn.

After I use Ctrl-C to stop the server, recompile and restart I realize that I can’t use the cursor key to recollect the commands from the previous session.

The cursor keys give only the commands I have entered in the new iex -S mix session.

Is that the normal behaviour? Command line tools mysql and psql have a history going back to previous sessions and I wonder if iex has the samel

I use this in my dev env
https://zen.id.au/how-to-make-the-elixir-shell-iex-save-history/

I would not use this in production (due to production paranoia :smiling_imp:).

2 Likes

I guess this is one question I can answer myself. I came across it when trying out erlang but couldn’t remember the debian package name, rlwrap

There is another option using a Erlang History

More about both here - http://stackoverflow.com/questions/22426716/how-to-save-log-the-output-of-the-iex-shell-to-get-persistent-command-history/28514369#28514369

Unfortunately, there is no such feature because it’s not supported by the underlying Erlang shell. There is a closed issue on Github which documents this: https://github.com/elixir-lang/elixir/issues/2945

The erlang-history module mentioned by @outlog and also referenced in the Gihub issue seems to be a little bit hacky and its author stated that the history might get corrupted from time to time. But still, better than no history at all, I suppose :wink:

2 Likes

Just as a note, this is how the shell works on everything but Windows.

For some reason on my work Windows 10 computer I get history going all the way back, and I also only have to hit Ctrl+c once, the job menu never appears (which sucks at times I do admit). I’m unsure why Windows has history and only have to hit Ctrl+c once, maybe @josevalim knows?