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

Display history
Most Liked
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
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
OK, latest version:
https://github.com/nhpip/history
In addition to saving history and bindings, this version adds:
-
Supports for aliasing the History module
-
Copy/paste a command from history to the shell (so you can edit it)
-
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 ]]
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance












