Last active
November 14, 2017 23:54
-
-
Save agwells/f6e1b2a6fcd12c5846d455d5a6f8ce29 to your computer and use it in GitHub Desktop.
My additions to my sitewide Rprofile file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use the special "Cloud repo" for CRAN | |
options(repos = structure(c(CRAN="https://cloud.r-project.org/"))) | |
if (interactive()) suppressMessages({ | |
# The packages I always want present by default at the prompt. | |
require(devtools) | |
require(magrittr) | |
# Display menu selection prompts in the terminal instead of an | |
# annoying popup GUI window. | |
options(menu.graphics = FALSE) | |
# Use my alternate pager script to make searches case-insensitive, and | |
# leave the screen uncleared when you close it (so that you can see the | |
# R help page content at the same time as the R prompt.) | |
options("pager" = file.path(Sys.getenv("HOME"), "programs/R-pager.sh")) | |
# Simpler quitting. Most of the time I don't want to save when I quit, | |
# so this saves me the time of having to type q("no") every time, or | |
# do that interactive prompt. | |
# | |
# Potentially there might be projects where I would prefer to autosave | |
# on quit. For those, I can set the option "saveOnQuit" to "yes". | |
quit = function( | |
save = getOption("saveOnQuit", default="no") | |
, ... | |
){ | |
base::quit(save, ...) | |
} | |
q = quit | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# My customized pager script. Everything below this comment block is identical to | |
# the R pager script installed by the R debian package at /usr/lib/R/bin/pager, | |
# except that I've replaced ${PAGER} with /bin/less explicitly, and added | |
# the -I and -X flags. | |
# | |
# The "-I" flag makes searches in the pager case-insensitive by default. | |
# The "-X" flag tells the pager not to clear the screen when it closes. That | |
# allows me to continue to see the help content at the same time as having | |
# the prompt available; which is helpful because I have the memory of a | |
# fruitfly and tend to mis-type commands unless I have the documentation | |
# right there in front of me. | |
# | |
# Inconveniently, a shell script is necessary for this, because R seems to | |
# try to verify that the "pager" option string is the path and name of an | |
# executable file, so doing.e.g option(pager="/bin/less -IX") will give an | |
# error along the lines of "No file named 'less -IX' found". | |
## For the curious: "pager $1" doesn't work in batch, because "more" will | |
## eat the rest of stdin. The no-argument version is intended for use at | |
## the end of a pipeline. | |
## | |
## PAGER is determined at configure time and recorded in `etc/Renviron'. | |
## This is documented to be a 'command line' so we do not quote it. | |
if test -n "${1}"; then | |
exec /bin/less -IX < ${1} | |
else | |
exec /bin/less -IX | |
fi | |
### Local Variables: *** | |
### mode: sh *** | |
### sh-indentation: 2 *** | |
### End: *** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One annoying note: Although R supports a system-wide Rprofile (
/etc/R/Rprofile.site
), a user-level Rprofile (~/.Rprofile
), and a directory-level Rprofile (/path/to/project/.Rprofile
) it doesn't load all three. The system-wide Rprofile is always loaded, but the user-level one is ignored if there is a directory-level Rprofile in the current directory. (This is different from how must other systems behave, which have a similar three-level config hierarchy.)Since I use Packrat, I am often working in a directory with a
.Rprofile
file in it. So to make sure my customizations get loaded every time, I added a line to my system-wide/etc/R/Rprofile.site
that loads this up.