The story about history

In the not so early days of Erlang, before Fred gave us erlang-history, Erlang’s shell history was ephemeral: it was lost as soon as you closed your node.

Many of us then had tons of Erlang snippets in sticky notes, text files or other documents that we copied&pasted every time we needed. Some crafty ones stored those things in user_default to have them constantly available (If you don’t know what I’m talking about, maybe this is a good time to read this tutorial). But still, leaving an Erlang shell was a pain that we tried to avoid at all costs.

On the other hand, most of us work with git, right? So, after a good round of testing/coding/compiling/etc. one would like to commit and push changes to the upstream repository. Git runs on the terminal, so whenever I wanted to use it I had to either keep 2 terminals (one for the Erlang shell and another for running git or other commands) or… close the Erlang shell, run the git commands and reopen it. Oh, the struggle!!

Well, actually… there was an alternative:

1345> io:format(“~s~n”, [os:cmd(“git status”)]).

…

ok

1346>

os:cmd/1 executes commands in the shell of the target OS. The result of that evaluation is an iolist with the output given by said commands. So, using io:format/2 with ~s I could print it out in the Erlang shell nicely.

But then again, that’s a lot of boilerplate for something that should have been just git status.