diff --git a/stdlib/REPL/docs/src/index.md b/stdlib/REPL/docs/src/index.md index 4e7dfca112b06..9d61b67740542 100644 --- a/stdlib/REPL/docs/src/index.md +++ b/stdlib/REPL/docs/src/index.md @@ -211,8 +211,10 @@ Just as `^R` is a reverse search, `^S` is a forward search, with the prompt ```( The two may be used in conjunction with each other to move through the previous or next matching results, respectively. -All executed commands in the Julia REPL are logged into `~/.julia/logs/repl_history.jl` along with a timestamp of when it was executed -and the current REPL mode you were in. Search mode queries this log file in order to find the commands which you previously ran. +All executed commands in the Julia REPL are logged into `~/.julia/logs/repl_history.jl` along with a timestamp of when it was executed, +a session id, +and the current REPL mode you were in. The session id is set at the start of execution of the REPL. +Search mode queries this log file in order to find the commands which you previously ran. This can be disabled at startup by passing the `--history-file=no` flag to Julia. ## Key bindings diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index 8e15bed447682..18ced3e7ede5a 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -29,7 +29,9 @@ import Base: display, show, AnyDict, - == + ==, + UUID, + rand _displaysize(io::IO) = displaysize(io)::Tuple{Int,Int} @@ -534,10 +536,11 @@ mutable struct REPLHistoryProvider <: HistoryProvider last_mode::Union{Nothing,Prompt} mode_mapping::Dict{Symbol,Prompt} modes::Vector{Symbol} + session::UUID end REPLHistoryProvider(mode_mapping::Dict{Symbol}) = REPLHistoryProvider(String[], nothing, 0, 0, -1, IOBuffer(), - nothing, mode_mapping, UInt8[]) + nothing, mode_mapping, UInt8[], UUID(rand(UInt128))) invalid_history_message(path::String) = """ Invalid history file ($path) format: @@ -614,6 +617,7 @@ function add_history(hist::REPLHistoryProvider, s::PromptState) entry = """ # time: $(Libc.strftime("%Y-%m-%d %H:%M:%S %Z", time())) # mode: $mode + # session: $(hist.session) $(replace(str, r"^"ms => "\t")) """ # TODO: write-lock history file