nhpip

nhpip

IExHistory2 - improved history, save variable bindings from the IEx shell and more...

Hello,

I wrote the initial version of this library as my first Elixir project a couple of years ago, mostly to learn Elixir, but also a desire to be able to save variable bindings between IEx sessions (especially useful when debugging). When the OTP team re-wrote the shell it caused it to break. I’ve been on a recent mission to fix it and update the code.

It’s still very much beta, but folks are more than welcome to play with it.

Here are the key features:

  • Saves IEx shell history between sessions / VM restarts.
  • Saves the shell variable bindings between sessions / VM restarts.
  • Ability to paste (most) terms into the shell without a screen full of garbage (experimental).
  • Navigation keys allow history traversal where multi-line pastes require a single key up/down (instead of up-arrowing every line of whatever was pasted). Unfortunately I had to chose different keys.
  • Shortcut functions permit search, pasting, re-evaluation and editing of items in history.
  • Editing can be done in-situ or in a text editor.
  • Shell variable bindings can be set/get outside of scope of the shell to assist in code debugging.
  • Can be enabled and state shared globally, or on individual shell sessions.

https://hexdocs.pm/iex_history2/IExHistory2.html#content

I really do some dirty hacks to get the bindings and history, it would be awesome if there was an official way to do that.

Most Liked

garazdawi

garazdawi

Erlang Core Team

The best way to get some official support is to open an issue at the Erlang/OTP github and describe what functionality you would like. Maybe we can design something together that would benefit everyone trying to build fancy shell things.

10
Post #2
nhpip

nhpip

The custom parser really helped clean up things. Thanks for the suggestion.

New version available:

garazdawi

garazdawi

Erlang Core Team

If you want to insert yourself between iex_server and group (i.e. the group_leader of iex_server, then you will have to get a hook into iex_server. The good thing here is that the protocol used between iex_server and group is documented so it should be relatively easy to insert something there if the Elixir team wants to allow it.

The protocol inbetween user_drv and group is however not documented and thus we cannot just add something that that snoops inbetween there. What exactly is it that you would like to do there?

In this example it seems like you would like to change the behaviour of the shell evaluator. Maybe it is possible to achieve by using a custom iex parser? If not, then that is yet another place in iex_server to insert yourself in. We don’t allow doing that in Erlang either, but I could see us adding such a feature if it was requested.

ken-kost

ken-kost

Tried it out, great stuff. :+1:
One note, readme reads:

Alternatively the project can be added as a Mix dependancy.

It’s a little confusing because I needed to add it as dependency, otherwise it wouldn’t work, I got:

Erlang/OTP 26 [erts-14.2.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.16.0) - press Ctrl+C to exit (type h() ENTER for help)
Error while evaluating: /home/ken/asher/.iex.exs
** (UndefinedFunctionError) function IExHistory2.initialize/0 is undefined (module IExHistory2 is not available)
    IExHistory2.initialize()
    /home/ken/asher/.iex.exs:2: (file)

So readme maybe could read:

Installation

Add :iex_history2 to the list of dependencies in `mix.exs``:

def deps do
  [
    {:iex_history2, "~> 5.1"}
  ]
end

Enable IExHistory2 in .iex.exs:

Code.append_path("~/github/iex_history2/_build/dev/lib/iex_history2/ebin")
IExHistory2.initialize()

I tried to open a PR for this but I get remote: Permission to nhpip/iex_history2.git denied to ken-kost. :disguised_face:

nhpip

nhpip

Hi,

I just updated the code to allow it to be included in mix as part of another application.

Let me know it works now

Thanks

Where Next?

Popular in Libraries Top

mathieuprog
Hello :wave: Allow me to introduce you to Tz, an alternative time zone database support to Tzdata. Why another library? First and fore...
New
cjen07
parameterized pipe in elixir: |n> edit: negative index in |n> and mixed usage with |> are supported example: use ParamP...
New
arkgil
Hi all! I’m happy to announce that Telemetry v0.3.0 is out! This release marks the conversion from Elixir to Erlang so that all the libr...
New
mcrumm
If you would like to migrate away from node/npm/webpack while still using sass, the dart_sass package provides a installer and runner for...
New
michalmuskala
Another small library today. PersistentEts Hex: persistent_ets | Hex GitHub: GitHub - michalmuskala/persistent_ets Ets table backed by...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
ericlathrop
I built a silly site for Halloween that uses Phoenix Channels on the backend, and React on the frontend. I had many problems integrating ...
New
gabrielpoca
Hello everyone! I want to share with you something that I’m really proud of: https://stillstatic.io/ Still is a static site builder for...
New
mattludwigs
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New
mplatts
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components. We also have a boi...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Sub Categories:

We're in Beta

About us Mission Statement