While trying the solution with .erlang
I stumbled upon a solution for the specific rr/1
usage:
From the man-page of shell:
There is some support for reading and printing records in the shell.
During compilation record expressions are translated to tuple expres-
sions. In runtime it is not known whether a tuple actually represents a
record. Nor are the record definitions used by compiler available at
runtime. So in order to read the record syntax and print tuples as
records when possible, record definitions have to be maintained by the
shell itself. The shell commands for reading, defining, forgetting,
listing, and printing records are described below. Note that each job
has its own set of record definitions. To facilitate matters record
definitions in the modules shell_default and user_default (if loaded)
are read each time a new job is started. For instance, adding the line
-include_lib("kernel/include/file.hrl").
to user_default makes the definition of file_info readily available in
the shell.
For clarification I add some example:
File foo.hrl
:
-record(foo, {bar, baz=5}).
File: user_default.erl
:
-module(user_default).
-compile(export_all).
-include("foo.hrl"). % include all relevant record definition headers here
%% more stuff probably ...
Lets try out in the shell:
$ erl
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.7.5 (abort with ^G)
1> #foo{}.
#foo{bar = undefined,baz = 5}
→ the shell knows about the record from foo.hrl