nhpip

nhpip

Improved? IEx shell history. My pet project/hack session

Hi,

https://github.com/nhpip/history

I wrote an initial version of this a month or 2 ago. I recently improved on it after I crashed my IEx shell at work.

Features:

1 Persist history
2 Persist the shell variable bindings (that get reloaded when you restart)
2 List history
3 Search history
4 Re-execute a command in history
5. Scoping rules
6. Update configuration

I probably broke some rules on how it was implemented, but it works for me. Feel free to play with it…Next on my list is to make it play better with the current IEx history.

Pics attached



Screen Shot 2021-09-01 at 3.55.48 PM

Display history

Most Liked

nhpip

nhpip

Thanks,

The problem withe ctrl+r is that it’s a line history, not a command history. So if, for example, you paste a large list, map or struct into the shell it renders it useless. I use the kernel flags too, but that’s a globally shared view which is fine in some cases, but not always (I also don’t think it includes date etc…plus I haven’t found a nice way to just show the history.

Still, as you said … it’s all for fun

Will-W

Will-W

Love a nice bit of code hacking.

Are you aware that you can do the following (in my case in .bashrc) and it will persist history?
export ERL_AFLAGS="-kernel shell_history enabled"

Between that and the normal readline shortcuts like ctrl+r I think most of what you’re looking for is built-in.

OTOH, if you’re building it for fun - nice work!

nhpip

nhpip

OK, latest version:

https://github.com/nhpip/history

In addition to saving history and bindings, this version adds:

  1. Supports for aliasing the History module

  2. Copy/paste a command from history to the shell (so you can edit it)

  3. Use ctrl+u and ctrl+k to move up and down history. Unlike the standard history search with the arrow keys this is command not line based. So, for example:

Paste:

iex(1)> config = [
...(1)>   scope: :local,
...(1)>   history_limit: :infinity,
...(1)>   hide_history_commands: true,
...(1)>   prepend_identifiers: true,
...(1)>   key_buffer_history: true,
...(1)>   command_display_width: :int,
...(1)>   save_invalid_results: false,
...(1)>   show_date: true,
...(1)>   save_bindings: true,
...(1)>   colors: [
...(1)>     index: :red,
...(1)>     date: :green,
...(1)>     command: :yellow,
...(1)>     label: :red,
...(1)>     variable: :green
...(1)>   ]
...(1)> ]
[
  scope: :local,
  history_limit: :infinity,
  hide_history_commands: true,
  prepend_identifiers: true,
  key_buffer_history: true,
  command_display_width: :int,
  save_invalid_results: false,
  show_date: true,
  save_bindings: true,
  colors: [
    index: :red,
    date: :green,
    command: :yellow,
    label: :red,
    variable: :green
  ]
]

ctrl+u:

iex(2)> config = [ scope: :local, history_limit: :infinity, hide_history_commands: true, prepend_identifiers: true, key_buffer_history: true, command_display_width: :int, save_invalid_results: false, show_date: true, save_bindings: true, colors: [ index: :red, date: :green, command: :yellow, label: :red, variable: :green ]]

Where Next?

Popular in Discussions Top

PragTob
Hello everyone, I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
Jayshua
I recently came across the javascript library htmx. It reminded me a lot of liveview so I thought the community here might be interested....
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
Qqwy
Looking at the stacks that existing large companies have used, WhatsApp internally uses Mnesia to store the messages, while Discord uses ...
New
WolfDan
After doing a port from a c++ library to my project in phoenix I’ve seen that I need a faster way to run this algorithm and I found this ...
New
pillaiindu
I want to convert a Phoenix LiveView CRUD website to a CRUD mobile app. What do you think is the easiest way to do so?
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
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

We're in Beta

About us Mission Statement