Some months ago we got a brand new REPL infrastructure. A couple of days
ago, we got a new ~/.julia_history file format, originally proposed here
<https://github.com/JuliaLang/julia/issues/6348>. It looks like this:

# time: 2014-06-07 14:03:47 EDT
# mode: julia
1 + 2
# time: 2014-06-07 14:04:04 EDT
# mode: julia
for x in "Hello, world."
    println(x)
end
# time: 2014-06-07 14:04:10 EDT
# mode: help
println
# time: 2014-06-07 14:04:15 EDT
# mode: shell
ls -l

Each entry is prefixed with a block of headers, including the time the
entry was saved and the input "mode" – i.e. "julia", "help" or "shell" (or
whatever other modes we may add in the future). After that comes the actual
multiline input, each line prefixed with a tab character. That's it.

[Why prefix each input line with a tab character, you ask? Because valid
inputs may begin with "#", so without the tabs you can't know when the
header is done and the inputs begins. With this scheme, every line of the
format either begins with a "#" or a tab. The history reader also ignores
blank lines before, during or after the metadata header and after the last
history entry, which makes the format a little less brittle.]

Benefits of this format:

   1. It supports arbitrary multiline inputs.
   2. It's easy to open in a text editor.
   3. It's easy to search with grep.
   4. You can cut-and-paste from history into the REPL easily and it
   preserves indentation.
   5. It keeps the time each entry was saved.
   6. It is easy to add additional metadata in the future.

I actually think this could be a pretty solid multiline history format for
other systems, but for now, I'm happy to have it for Julia.

What you need to do: you will see an error if you try to start the REPL
with a ~/.julia_history file in the old format. It will tell you to rename
or delete that file and start the REPL again. Do that.

Reply via email to