# The Erlang Shell

**URL:** <https://erlangforums.com/t/the-erlang-shell/1307>\
**Category:** Official Proposals\
**Tags:** shell\
**Created:** [April 11, 2022, 9:23am UTC](https://erlangforums.com/t/the-erlang-shell/1307 "2022-04-11T09:23:48Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![Maria-12648430](https://erlangforums.com/user_avatar/erlangforums.com/maria-12648430/32/604_2.png) [@Maria-12648430](https://erlangforums.com/u/Maria-12648430)\
**Post date:** [May 6, 2022, 8:22pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/81 "2022-05-06T20:22:37Z")

</div>

> [@juhlig](#):
>
> Those were the days 🤩

What century was that again? 😁

> [@AstonJ](#):
>
> mouse

Filthy rodent vermin… 🫣

> [@garazdawi](#):
>
> On the other hand, I quite like that Erlang has the same key binding no matter if I am on windows, macos or Linux.

For that use case (which probably _is_ rare), there could be an Erlang-as-you-know-it key binding which you can install and use on all environments you are using 🤷‍♀️

---

<div class="post-metadata">

**Author:** ![juhlig](https://erlangforums.com/user_avatar/erlangforums.com/juhlig/32/837_2.png) [@juhlig](https://erlangforums.com/u/juhlig)\
**Post date:** [May 6, 2022, 8:26pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/82 "2022-05-06T20:26:59Z")

</div>

> [@Maria-12648430](#):
>
> What century was that again? 😁

“At the Time When Things Were Otherwise and the Moon was Different” 😝

---

<div class="post-metadata">

**Author:** ![Maria-12648430](https://erlangforums.com/user_avatar/erlangforums.com/maria-12648430/32/604_2.png) [@Maria-12648430](https://erlangforums.com/u/Maria-12648430)\
**Post date:** [May 6, 2022, 8:29pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/83 "2022-05-06T20:29:42Z")

</div>

> [@juhlig](#):
>
> “At the Time When Things Were Otherwise and the Moon was Different” 😝

🤔 … Pratchett?

---

<div class="post-metadata">

**Author:** ![juhlig](https://erlangforums.com/user_avatar/erlangforums.com/juhlig/32/837_2.png) [@juhlig](https://erlangforums.com/u/juhlig)\
**Post date:** [May 6, 2022, 8:32pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/84 "2022-05-06T20:32:14Z")

</div>

> [@Maria-12648430](#):
>
> Pratchett?

Correct 😉 “Nation”, unless I am mistaken.

---

<div class="post-metadata">

**Author:** ![GuillaumeMilan](https://erlangforums.com/user_avatar/erlangforums.com/guillaumemilan/32/1464_2.png) [@GuillaumeMilan](https://erlangforums.com/u/GuillaumeMilan)\
**Post date:** [May 19, 2022, 9:53am UTC](https://erlangforums.com/t/the-erlang-shell/1307/85 "2022-05-19T09:53:57Z")

</div>

> [@garazdawi](#):
>
> The [kernel application](https://www.erlang.org/doc/man/kernel_app.html) allows configuration of a shell history. You can enable it using `erl -kernel shell_history enabled`, or setting `ERL_FLAGS=-kernel shell_history enabled`. Is this what you mean, or something different?

For me a good history management would allow people to store history in separated files. This would avoid sharing history across multiple projects.

```erlang
erl -kernel_shell_history enabled -kernel_shell_history_dir ./shell_history

```

Plus the capability to have multiple history for one node. For instance when you have a server that expose an ssh connection, the shell history is the node shell history. Which is not that great for multi users node or clusters.

---

<div class="post-metadata">

**Author:** ![GuillaumeMilan](https://erlangforums.com/user_avatar/erlangforums.com/guillaumemilan/32/1464_2.png) [@GuillaumeMilan](https://erlangforums.com/u/GuillaumeMilan)\
**Post date:** [May 19, 2022, 9:56am UTC](https://erlangforums.com/t/the-erlang-shell/1307/86 "2022-05-19T09:56:43Z")

</div>

> [@galdor](#):
>
> Having support for the very common Control-L shortcut to clear the terminal while in the shell would be incredibly beneficial to clear the mess after several commands.

The capability to capture control sequence in the IO protocol is key. This is missing when wanting to implement your own control sequence. And in the `ssh` module it makes it impossible to make the connection quit on Control-D as nothing can be captured.

---

<div class="post-metadata">

**Author:** ![garazdawi](https://erlangforums.com/user_avatar/erlangforums.com/garazdawi/32/175_2.png) [@garazdawi](https://erlangforums.com/u/garazdawi)\
**Post date:** [May 19, 2022, 10:29am UTC](https://erlangforums.com/t/the-erlang-shell/1307/87 "2022-05-19T10:29:24Z")

</div>

> [@GuillaumeMilan](#):
>
> For me a good history management would allow people to store history in separated files. This would avoid sharing history across multiple projects.
> 
> ```erlang
> erl -kernel_shell_history enabled -kernel_shell_history_dir ./shell_history
> 
> ```

Do you mean what `-kernel shell_history_path Dir` does? Or is something missing with that implementation?

> [@GuillaumeMilan](#):
>
> Plus the capability to have multiple history for one node. For instance when you have a server that expose an ssh connection, the shell history is the node shell history. Which is not that great for multi users node or clusters.

Since Erlang has no concept of multiple users it is not obvious (at least to me) how to select which history it should use. For ssh it could be possible to do better, but for `-remsh` I’m unsure what to do.

> [@GuillaumeMilan](#):
>
> The capability to capture control sequence in the IO protocol is key.

Being able to configure all sorts of key binding and what is captured is one of the things on our list of things to do. So this should be possible to achieve when we are done.

---

<div class="post-metadata">

**Author:** ![kjnilsson](https://erlangforums.com/user_avatar/erlangforums.com/kjnilsson/32/450_2.png) [@kjnilsson](https://erlangforums.com/u/kjnilsson)\
**Post date:** [May 19, 2022, 11:40am UTC](https://erlangforums.com/t/the-erlang-shell/1307/88 "2022-05-19T11:40:41Z")

</div>

One thing I used a lot when working with F# in the past is editing code in my editor then sending an expression or function to a running F# shell for evaluation and testing. Perhaps this is already possible right now?

I haven’t read every comment above so apologies if this has already been mentioned.

---

<div class="post-metadata">

**Author:** ![garazdawi](https://erlangforums.com/user_avatar/erlangforums.com/garazdawi/32/175_2.png) [@garazdawi](https://erlangforums.com/u/garazdawi)\
**Post date:** [May 19, 2022, 5:54pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/89 "2022-05-19T17:54:39Z")

</div>

> [@kjnilsson](#):
>
> One thing I used a lot when working with F# in the past is editing code in my editor then sending an expression or function to a running F# shell for evaluation and testing. Perhaps this is already possible right now?

I think that would be something for ErlangLS or your favourite code editor to do. Not sure the shell can help out all that much there except being better at parsing all valid Erlang code (macros, attributes, functions etc).

---

<div class="post-metadata">

**Author:** ![phild](https://erlangforums.com/user_avatar/erlangforums.com/phild/32/742_2.png) [@phild](https://erlangforums.com/u/phild)\
**Post date:** [May 21, 2022, 9:12am UTC](https://erlangforums.com/t/the-erlang-shell/1307/90 "2022-05-21T09:12:48Z")

</div>

Apologies if this has already been covered, but I’d like to be able to paste code from a .erl file into a vanilla shell and have it just work such as:

```erlang
1> -type foo() :: 1..20.
2> -record('Things', {
2> 'One' :: foo(),
2> 'Two' :: foo(),
3> 'Tri' :: string()
3> }).
4> record_info(fields, 'Things').

```

In the above contrived example, neither `-type` nor `record_info` currently work in the shell.

---

<div class="post-metadata">

**Author:** ![kura](https://erlangforums.com/user_avatar/erlangforums.com/kura/32/304_2.png) [@kura](https://erlangforums.com/u/kura)\
**Post date:** [May 21, 2022, 9:27am UTC](https://erlangforums.com/t/the-erlang-shell/1307/91 "2022-05-21T09:27:09Z")

</div>

Indeed, Karl’s favourite editor can do that. 😉 I’ve recorded a quick demo. I’m using [GitHub - akinsho/toggleterm.nvim: A neovim lua plugin to help easily manage multiple terminal windows](https://github.com/akinsho/toggleterm.nvim) (another popular plugin is [GitHub - numToStr/FTerm.nvim: No-nonsense floating terminal plugin for neovim](https://github.com/numToStr/FTerm.nvim)):

[https://asciinema.org/a/496194](https://asciinema.org/a/496194)

In real life, the commands would be mapped to some keys of course, but I’m showing full commands to make it clear what is going on.

UPDATE: I just noticed that some colors were lost when recording using [https://asciinema.org](https://asciinema.org) so some UI elements look strange but whatever - you get the idea and asciinema is still awesome.

---

<div class="post-metadata">

**Author:** ![DevotionGeo](https://erlangforums.com/user_avatar/erlangforums.com/devotiongeo/32/213_2.png) [@DevotionGeo](https://erlangforums.com/u/DevotionGeo)\
**Post date:** [May 22, 2022, 1:00am UTC](https://erlangforums.com/t/the-erlang-shell/1307/92 "2022-05-22T01:00:23Z")

</div>

I wish **Vim mode** was possible in **iex** and **erl**. I use it all the time in **zsh**.

---

<div class="post-metadata">

**Author:** ![filmor](https://erlangforums.com/user_avatar/erlangforums.com/filmor/32/988_2.png) [@filmor](https://erlangforums.com/u/filmor)\
**Post date:** [May 24, 2022, 11:25am UTC](https://erlangforums.com/t/the-erlang-shell/1307/93 "2022-05-24T11:25:57Z")

</div>

One thing that just came to my mind: A nicer message handling would be great. It could be just simple things, like an indication of the queue size on the prompt or (and this is what I’d like the most) timestamps on `flush().` 🙂

---

<div class="post-metadata">

**Author:** ![dominic](https://erlangforums.com/letter_avatar_proxy/v4/letter/d/13edae/32.png) [@dominic](https://erlangforums.com/u/dominic)\
**Post date:** [May 25, 2022, 6:12am UTC](https://erlangforums.com/t/the-erlang-shell/1307/94 "2022-05-25T06:12:35Z")

</div>

a record prompt like:

```erlang
1>rd(record, {a, b, c}).
2># recor\tab
2>#record
2>#record.\tab
a b c

```

I have try it with my web shell, it’s nice to use 😄

---

<div class="post-metadata">

**Author:** ![nhpip](https://erlangforums.com/letter_avatar_proxy/v4/letter/n/3bc359/32.png) [@nhpip](https://erlangforums.com/u/nhpip)\
**Post date:** [June 2, 2022, 12:59pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/95 "2022-06-02T12:59:03Z")

</div>

Option to remember variable bindings…see…

This is something I wrote for Elixir as my first project. Basically a more advanced history: [GitHub - nhpip/history: An improved history for the Elixir IEx shell](https://github.com/nhpip/history)

Highlights:

1. History saved between shell sessions
2. Remembers variable bindings between shell sessions
3. Nicer presented history
4. Execute and/or copy commands previously issued
5. Scroll up/down history but pasting of a large term or code will be thought of a single line instead of many
6. History/bindings are remembered per node name or globally

---

<div class="post-metadata">

**Author:** ![josevalim](https://erlangforums.com/user_avatar/erlangforums.com/josevalim/32/353_2.png) [@josevalim](https://erlangforums.com/u/josevalim)\
**Post date:** [June 18, 2022, 3:52pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/96 "2022-06-18T15:52:03Z")

</div>

Another feature request is the ability to start the shell at any moment in the code. There is no official API to do so and Rebar hacks it in order to get `rebar3 shell` to work: [rebar3/rebar\_prv\_shell.erl at fc52e08b400e4e1cae980368577ed69c2bfd0653 · erlang/rebar3 · GitHub](https://github.com/erlang/rebar3/blob/fc52e08b400e4e1cae980368577ed69c2bfd0653/src/rebar_prv_shell.erl#L141) 🙂

---

<div class="post-metadata">

**Author:** ![dischoen](https://erlangforums.com/user_avatar/erlangforums.com/dischoen/32/695_2.png) [@dischoen](https://erlangforums.com/u/dischoen)\
**Post date:** [July 1, 2022, 10:44am UTC](https://erlangforums.com/t/the-erlang-shell/1307/97 "2022-07-01T10:44:09Z")

</div>

On documentation helpers:  
I could use a version of h() which allows the “regular” form of a function with the module:function form:  
e.g. h(erlang:system\_time).

This would allow me to copypaste directly to h().  
Now I have to copy the module:function and replace the colon with a comma.

---

<div class="post-metadata">

**Author:** ![garazdawi](https://erlangforums.com/user_avatar/erlangforums.com/garazdawi/32/175_2.png) [@garazdawi](https://erlangforums.com/u/garazdawi)\
**Post date:** [August 18, 2022, 7:54am UTC](https://erlangforums.com/t/the-erlang-shell/1307/98 "2022-08-18T07:54:50Z")

</div>

At the moment, anything typed in the Erlang shell has to be valid erlang syntax, which `h(erlang:system_time)` is not. I too would have liked it to be possible to type what you propose, but it is not trivial to get working.

---

<div class="post-metadata">

**Author:** ![filmor](https://erlangforums.com/user_avatar/erlangforums.com/filmor/32/988_2.png) [@filmor](https://erlangforums.com/u/filmor)\
**Post date:** [August 18, 2022, 8:07am UTC](https://erlangforums.com/t/the-erlang-shell/1307/99 "2022-08-18T08:07:40Z")

</div>

Would `fun erlang:system_time/_` be an option?

---

<div class="post-metadata">

**Author:** ![garazdawi](https://erlangforums.com/user_avatar/erlangforums.com/garazdawi/32/175_2.png) [@garazdawi](https://erlangforums.com/u/garazdawi)\
**Post date:** [August 18, 2022, 8:16am UTC](https://erlangforums.com/t/the-erlang-shell/1307/100 "2022-08-18T08:16:47Z")

</div>

It needs to be an executable expression, so `fun erlang:system_time/1` would work, but I’m not sure how much easier that is to write?

[Previous page](https://erlangforums.com/t/the-erlang-shell/1307.md?page=4)

[Next page](https://erlangforums.com/t/the-erlang-shell/1307.md?page=6)
