# 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:** 3

<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:** [April 13, 2022, 7:33am UTC](https://erlangforums.com/t/the-erlang-shell/1307/41 "2022-04-13T07:33:53Z")

</div>

> [@crownedgrouse](#):
>
> Being able to jail functions using paths below a directory.

Would you mind expanding on what you mean here with an example?

Thanks for all the other suggestions, I think we should be able to do most of them although tab-completion for filenames may be a bit tricky…

---

<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:** [April 13, 2022, 7:46am UTC](https://erlangforums.com/t/the-erlang-shell/1307/42 "2022-04-13T07:46:26Z")

</div>

> [@nato](#):
>
> Fred wrote the command history/search I believe. One snafu I had with it was when I use erl\_pipe (with releases) and use the search history. A pattern that I typically use to get-out-of search mode is ctrl-d … this breaks the erl\_pipe session … and I have done this 100 times. I wonder if it’s just me or what…
> 
> If I remember, the search history was based on a popular shell… and I believe ctrl+d was the normal way of breaking out of search in that inspiring shell. So to have the erlang shell close (when erl\_pipe) on you, is a shame, at very least. This isn’t an issue for a standard erlang shell, or course.

I use Ctrl+A or Ctrl+E to break out of search as using Ctrl+D while searching in bash will exit the shell…

> [@nato](#):
>
> This would be super great too: if ctrl+] (which currently closes some brackets, braces, parenthesis) also closed double quotes, single quotes, and the trailing greater-than+greater-than for binaries ( \<\<“foo”\>\>, \<\<42\>\> ). Wow, that would be amazing.

Great idea, added to the list of things to look at!

---

<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:** [April 13, 2022, 7:56am UTC](https://erlangforums.com/t/the-erlang-shell/1307/43 "2022-04-13T07:56:51Z")

</div>

> [@stefanchrobot](#):
>
> I’m not sure about the internals and if I’m messing things up (please correct me if I’m wrong), but isn’t the screen clearing and history be handled by supporting [Readline](https://tiswww.case.edu/php/chet/readline/rltop.html) (or similar) integration?

We are trying to bring the Windows and Unix shell experience closer together and from what I can tell there is no readline for Windows (though I have only done some cursory checking, so I may be wrong). It seems like ruby/pry have gotten around that by building a pure ruby version of readline, which is kind of what the internal shell implementation of Erlang does today.

Maybe there is someway to use readline if it is available so that you can get all of the goodies, but still have a relatively similar shell for Windows…

---

<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:** [April 13, 2022, 1:56pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/44 "2022-04-13T13:56:11Z")

</div>

> [@nato](#):
>
> This would be super great too: if ctrl+] (which currently closes some brackets, braces, parenthesis)

I had no idea about this! This is great!

---

<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:** [April 13, 2022, 2:02pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/45 "2022-04-13T14:02:24Z")

</div>

There is a [chapter hidden away](https://www.erlang.org/doc/apps/erts/tty.html) in the Erts User’s Guide with some of the keybindings available in the shell. `Ctrl+]` is the in there, but also a few others that I did not know about.

---

<div class="post-metadata">

**Author:** ![AstonJ](https://erlangforums.com/user_avatar/erlangforums.com/astonj/32/9_2.png) [@AstonJ](https://erlangforums.com/u/AstonJ)\
**Post date:** [April 13, 2022, 2:57pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/46 "2022-04-13T14:57:04Z")

</div>

This is awesome! Would it be possible include some standard Mac commands using the command key? Such as `CMD`+`<` for beginning of line and `CMD`+`>` for end of line? For many Mac users these are hard-wired into our brains :lol:

**Edit** : Just realised in Terminal App those shortcuts jump between windows… however `option` and the arrow keys jump to the beginning/end of line :023:

---

<div class="post-metadata">

**Author:** ![crownedgrouse](https://erlangforums.com/user_avatar/erlangforums.com/crownedgrouse/32/591_2.png) [@crownedgrouse](https://erlangforums.com/u/crownedgrouse)\
**Post date:** [April 13, 2022, 6:08pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/47 "2022-04-13T18:08:27Z")

</div>

I mean that a kernel (?) config should be existing to jail any disk access for functions into a root directory .  
This way only system could open config elsewhere before shell start.  
This to avoid any rogue attempt to modify config or read some keys or private data.  
I add this should also apply to function call via rpc.

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://erlangforums.com/user_avatar/erlangforums.com/overminddl1/32/398_2.png) [@OvermindDL1](https://erlangforums.com/u/OvermindDL1)\
**Post date:** [April 13, 2022, 9:44pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/48 "2022-04-13T21:44:25Z")

</div>

> [@AstonJ](#):
>
> beginning/end of line

You don’t just hit Home/End keys?!

---

<div class="post-metadata">

**Author:** ![AstonJ](https://erlangforums.com/user_avatar/erlangforums.com/astonj/32/9_2.png) [@AstonJ](https://erlangforums.com/u/AstonJ)\
**Post date:** [April 13, 2022, 11:21pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/49 "2022-04-13T23:21:27Z")

</div>

We don’t have those on the smaller Apple keyboards :lol:

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://erlangforums.com/user_avatar/erlangforums.com/overminddl1/32/398_2.png) [@OvermindDL1](https://erlangforums.com/u/OvermindDL1)\
**Post date:** [April 14, 2022, 3:42pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/50 "2022-04-14T15:42:43Z")

</div>

That is _horrifying_, lol. Even my crappy old dell laptop at work has those. ^.^;

Home/End is used for _so_ much! How do you replicate the action of Ctrl+Home/End, or Shift+Home/End, or Ctrl+Shift+Home/End, or Alt+Home/End, or all the other combinations that I use on an hourly basis?!?

---

<div class="post-metadata">

**Author:** ![adolfont](https://erlangforums.com/user_avatar/erlangforums.com/adolfont/32/402_2.png) [@adolfont](https://erlangforums.com/u/adolfont)\
**Post date:** [April 14, 2022, 4:18pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/51 "2022-04-14T16:18:55Z")

</div>

Would multiline editing allow us to type a full module, as Elixir allows us?

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://erlangforums.com/user_avatar/erlangforums.com/overminddl1/32/398_2.png) [@OvermindDL1](https://erlangforums.com/u/OvermindDL1)\
**Post date:** [April 14, 2022, 4:31pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/52 "2022-04-14T16:31:00Z")

</div>

No, that would require more substantial changes to the shell parser, including the ability to call into the compiler then.

---

<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:** [April 14, 2022, 5:45pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/53 "2022-04-14T17:45:11Z")

</div>

As @OvermindDL1 said, it will require different changes to what multi line editing entails. However, we will be looking at allowing modules to be defined in the shell. Not sure yet if it can be done in a satisfactory way.

---

<div class="post-metadata">

**Author:** ![crownedgrouse](https://erlangforums.com/user_avatar/erlangforums.com/crownedgrouse/32/591_2.png) [@crownedgrouse](https://erlangforums.com/u/crownedgrouse)\
**Post date:** [April 15, 2022, 12:08pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/54 "2022-04-15T12:08:21Z")

</div>

A kind of ‘chroot’, defining path configured in this config as new rootdir “/” for all disk functions calls, after kernel start.

---

<div class="post-metadata">

**Author:** ![cmo](https://erlangforums.com/user_avatar/erlangforums.com/cmo/32/405_2.png) [@cmo](https://erlangforums.com/u/cmo)\
**Post date:** [April 15, 2022, 8:58pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/55 "2022-04-15T20:58:27Z")

</div>

PowerShell 7.2 has [PSReadLine](https://docs.microsoft.com/en-us/powershell/module/psreadline/about/about_psreadline?view=powershell-7.2) bundled.

---

<div class="post-metadata">

**Author:** ![cdybedahl](https://erlangforums.com/letter_avatar_proxy/v4/letter/c/45deac/32.png) [@cdybedahl](https://erlangforums.com/u/cdybedahl)\
**Post date:** [April 17, 2022, 8:49am UTC](https://erlangforums.com/t/the-erlang-shell/1307/56 "2022-04-17T08:49:20Z")

</div>

I’d like to see better support for running the shell via the Erlang ssh application in its daemon mode. Both in the way of making the ssh application easier to configure (not relying on keys in files on local disk, for example), and in making more shell functionality work well (today the shell break mode isn’t there at all, for example).

Direct Erlang shell access via ssh with a user experience that’s on par with that of running `erl` from a local shell would remove much of the need for developers to have shell access to servers, at least for us.

---

<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:** [April 17, 2022, 9:15am UTC](https://erlangforums.com/t/the-erlang-shell/1307/57 "2022-04-17T09:15:32Z")

</div>

I was checking on psreadline, and while it claims to be inspired by gnu readline it (to me) seems to be a very different tool. More of an adaption/extension of ps than a way for programs implement their own shells.

I’ll dig a bit more, but it does not seem like we can use it to build a good shell for Erlang.

---

<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:** [April 17, 2022, 9:17am UTC](https://erlangforums.com/t/the-erlang-shell/1307/58 "2022-04-17T09:17:08Z")

</div>

That doesn’t have anything to do with the shell though and I would say it can be better solved by os level tools.

---

<div class="post-metadata">

**Author:** ![crownedgrouse](https://erlangforums.com/user_avatar/erlangforums.com/crownedgrouse/32/591_2.png) [@crownedgrouse](https://erlangforums.com/u/crownedgrouse)\
**Post date:** [April 17, 2022, 9:27am UTC](https://erlangforums.com/t/the-erlang-shell/1307/59 "2022-04-17T09:27:12Z")

</div>

No, i think you didn’t understood the need.  
I’m not talking of an OS chroot that can come too. I’m talking about jailing users using shell once connected to avoid any attempt to change config. Restricted shell exists in Erlang but this would require to customize all erlang function accessing to disk. I’m even not sure i know all of them. We need to separate disk access between node itself and shell. No security will ever happen in Erlang without this.

---

<div class="post-metadata">

**Author:** ![starbelly](https://erlangforums.com/user_avatar/erlangforums.com/starbelly/32/209_2.png) [@starbelly](https://erlangforums.com/u/starbelly)\
**Post date:** [April 18, 2022, 3:02pm UTC](https://erlangforums.com/t/the-erlang-shell/1307/60 "2022-04-18T15:02:36Z")

</div>

I’ve wanted to fix #4337. Having difficulty finding time. Will try to revisit if OTP team can’t.

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

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