Skip to contents

Save named snapshots of your RStudio preferences that you can apply later.

  • snapshot_prefs_save(): Save your RStudio user preferences with a name that you can later use to identify these particular settings.

  • snapshot_prefs_use(): Apply a saved snapshot.

  • snapshot_prefs_list(): List available snapshots.

  • snapshot_prefs_undo(): Undo the last applied snapshot.

Usage

snapshot_prefs_save(
  name,
  path = NULL,
  include = NULL,
  exclude = NULL,
  source = "user",
  exclude_os_prefs = TRUE,
  overwrite = FALSE,
  preview = FALSE
)

snapshot_prefs_use(
  name = NULL,
  path = NULL,
  exclude_os_prefs = TRUE,
  verbose = FALSE,
  preview = FALSE
)

snapshot_prefs_list(path = NULL, verbose = TRUE)

snapshot_prefs_undo(verbose = TRUE)

Arguments

name

The name of the snapshot to save or apply.

  • In snapshot_prefs_save(), set to NULL to show the preferences that would be included in the snapshot.

  • In snapshot_prefs_use(), set to NULL to list available snapshots.

path

A GitHub gist ID or local path where the snapshot should be saved. To create a new public gist, set path = "new gist". For a new private gist, use path = "new private gist".

include

Names of RStudio preferences to include. If provided, only these preferences are included. See prefs_rstudio for preference names.

exclude

Names of RStudio preferences to exclude from the snapshot. See prefs_rstudio for all of the preference names.

source

The source of the current preference value. Preferences are set at different levels, from lowest to highest precedence:

  • "default" are RStudio's built-in defaults

  • "computed" are detected or supplied from external sources, e.g. the path to git on your system

  • "system" are derived from system-wide rstudio-prefs.json

  • "user" are set by the user for all sessions (global options)

  • "project" are set by the current project session

The default is "user", since these are the settings you set yourself for all projects. You can include any number of sources, or "all" to include all preferences regardless of source.

exclude_os_prefs

Excludes operating-system or machine-dependent system preferences from the snapshot or the snapshot restore.

overwrite

If the snapshot exists, should it be overwritten?

preview

When TRUE, previews the preferences that will be or are included in the snapshot, but does not save or apply them.

verbose

Prints or suppress informative output

Examples

if (interactive()) {
  tmpfile <- tempfile(fileext = ".json")
  snapshot_prefs_save("example", path = tmpfile)
  snapshot_prefs_list(tmpfile)
}