I'm using the R software for statistical analysis and am sad that it doesn't preserve and restore my prompt command history. Indeed, pressing the up arrow on a newly started interactive R session will reveal a blank history, every time. It would be great if it could do this in manner, say, similar to ipython. I tried putting this in my .Rprofile file to no avail. No file containing my command history is ever created.

.First <- function(){
        if (!any(commandArgs()=='--no-readline') && interactive()){
                require(utils)
                try(loadhistory(Sys.getenv("R_HISTFILE")))
        }
}

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

Of course this line is present in my .bash_profile

export R_HISTFILE="$HOME/share/r_libs/.history"

All this is happening via SSH on a remote server running Linux. Any help greatly appreciated !

Edit
Report