Rev 47704 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/utils/man/savehistory.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2007 R Core Development Team% Distributed under GPL 2 or later\name{savehistory}\alias{loadhistory}\alias{savehistory}\alias{history}\alias{timestamp}\title{Load or Save or Display the Commands History}\description{Load or save or display the commands history.}\usage{loadhistory(file = ".Rhistory")savehistory(file = ".Rhistory")history(max.show = 25, reverse = FALSE, pattern, \dots)timestamp(stamp = date(),prefix = "##------ ", suffix = " ------##",quiet = FALSE)}\arguments{\item{file}{The name of the file in which to save the history, orfrom which to load it. The path is relative to the currentworking directory.}\item{max.show}{The maximum number of lines to show. \code{Inf} willgive all of the currently available history.}\item{reverse}{logical. If true, the lines are shown in reverseorder. Note: this is not useful when there are continuation lines.}\item{pattern}{A character string to be matched against the lines ofthe history}\item{\dots}{Arguments to be passed to \code{\link{grep}} when doingthe matching.}\item{stamp}{A value or vector of values to be written into the history.}\item{prefix}{A prefix to apply to each line.}\item{suffix}{A suffix to apply to each line.}\item{quiet}{If \code{TRUE}, suppress printing timestamp to the console.}}\details{There are several history mechanisms available for the different \Rconsoles, which work in similar but not identical ways. Other uses of\R, in particular embedded uses, may have no history.#ifdef windowsThis works in Rgui and interactive Rterm but not in batch use of Rtermnor in embedded/DCOM versions.The history mechanism is controlled by two environment#endif#ifdef unixThis works under the \code{readline} and GNOME and Mac OS X consoles,but not otherwise (for example, in batch use or in an embedded application).The \code{readline} history mechanism is controlled by two environment#endifvariables: \code{R_HISTSIZE} controls the number of lines that aresaved (default 512), and \code{R_HISTFILE} sets the filename used forthe loading/saving of history if requested at the beginning/end of asession (but not the default for these functions). There is no limiton the number of lines of history retained during a session, sosetting \code{R_HISTSIZE} to a large value has no penalty unless alarge file is actually generated.These variables are read at the time of saving, so can be alteredwithin a session by the use of \code{\link{Sys.setenv}}.\code{history} shows only unique matching lines if \code{pattern} issupplied.The \code{timestamp} function writes a timestamp (or other message)into the history and echos it to the console. On platforms that do notsupport a history mechanism (where the mechanism does not yet supporttimestamps) only the console message is printed.}\note{If you want to save the history (almost) every session, you can put acall to \code{savehistory()} in \code{\link{.Last}}. See the examples.}\examples{\dontrun{.Last <- function()if(interactive()) try(savehistory("~/.Rhistory"))}}\keyword{utilities}