Bug 16227 - Improve handling of history across multiple sessions
Summary: Improve handling of history across multiple sessions
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R-devel (trunk)
Hardware: All Linux
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-03-02 03:28 UTC by Keith Hughitt
Modified: 2015-03-02 03:28 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Hughitt 2015-03-02 03:28:10 UTC
Currently, the ability to preserve history across sessions can be supported by editing one's ~/.Rprofile to include something like:

.Last <- function() {
    # Preserve history across sessions
    if (!any(commandArgs()=='--no-readline') && interactive()){
        require(utils)
        try(savehistory(Sys.getenv("R_HISTFILE")))
    }
}


In general this seems to work fairly well for a single session, or across single sessions over time.

The behavior is not ideal, however, when working in multiple R sessions simultaneously. In this case, it seems like the last session closed usually clobbers everything before it.

For example:

1) Delete ~/.Rhistory
2) Open one R session
3) Open a second R session
4) In the first R session, enter "1"
5) In the second R session, enter "2"
6) Exit the first R session # .Rhistory now contains "1"
7) Exit the second R session # .Rhistory now contains "2"

Ideally, the history would play well even across numerous sessions, similar to how shell histories work.

This is something that would make a huge difference in my (and I suspect many others) everyday work with R.