Title: | 'Rstudio' Addin to Sync Settings and Keymaps |
---|---|
Description: | Provides a 'Rstudio' addin to download, merge and upload 'Rstudio' settings and keymaps, essentially 'syncing them' at will. It uses 'Google Drive' as a cloud storage to keep the settings and keymaps files. |
Authors: | André Plancha [aut, cre] |
Maintainer: | André Plancha <[email protected]> |
License: | Apache License (== 2) |
Version: | 3.0.2 |
Built: | 2025-03-11 04:00:23 UTC |
Source: | https://github.com/notplancha/settingssync |
These functions are used to simulate the main functions before truly running them, to disable changes to the files and to the cloud.
mimic_on() mimic_off() is_mimic_on()
mimic_on() mimic_off() is_mimic_on()
These are used in most examples, so the user settings don't change when running [utils::example()]. Internally, these change the options 'ss.mimic', 'ss.mimic.local' and 'ss.mimic.cloud'.
nothing
mimic_on()
: Enable mimic and write mimic files
mimic_off()
: Disable mimic
is_mimic_on()
: Check if mimic is on
mimic_on() if(interactive()) { sync() } mimic_off()
mimic_on() if(interactive()) { sync() } mimic_off()
Pulls Rstudio settings from Google Drive, without pushing. This is just a helper function for [sync()], the main function, but can be used alone, although this function will not do any checking, and will just override.
pull( all = FALSE, addins_gd = FALSE, editor_bindings_gd = FALSE, rstudio_bindings_gd = FALSE )
pull( all = FALSE, addins_gd = FALSE, editor_bindings_gd = FALSE, rstudio_bindings_gd = FALSE )
all |
boolean, if TRUE will pull all settings from gd, overwriting them. This param overrides the values of the other params. Default is FALSE. |
addins_gd , editor_bindings_gd , rstudio_bindings_gd
|
character or boolean, the json string to be written to the respective file or TRUE/FALSE; if TRUE, will read from Google Drive; if FALSE to not write that specific file. Default is FALSE |
nothing
[read_from_gd()], [sync()], [push()]
mimic_on() pull() # does nothing pull(all = TRUE) # will pull all settings from gd, overwriting them pull(addins_gd = '{"insertPipeOperator": "Shift+Tab"}',) # will write to addins.json the string pull( addins_gd = '{"insertPipeOperator": "Shift+Tab"}', editor_bindings_gd= TRUE ) # will write to addins.json the string and pull editor_bindings from gd mimic_off()
mimic_on() pull() # does nothing pull(all = TRUE) # will pull all settings from gd, overwriting them pull(addins_gd = '{"insertPipeOperator": "Shift+Tab"}',) # will write to addins.json the string pull( addins_gd = '{"insertPipeOperator": "Shift+Tab"}', editor_bindings_gd= TRUE ) # will write to addins.json the string and pull editor_bindings from gd mimic_off()
Pushes Rstudio settings to Google Drive, without pulling. This is just a helper function for [sync()], the main function, but can be used alone, although this function will not do any checking, and will just override. Because of the way [googledrive::drive_put] is built, this function reads from the files directly.
push( do_all = FALSE, do_addins = FALSE, do_editor_bindings = FALSE, do_rstudio_bindings = FALSE, progBar = NULL )
push( do_all = FALSE, do_addins = FALSE, do_editor_bindings = FALSE, do_rstudio_bindings = FALSE, progBar = NULL )
do_all |
boolean, if TRUE will push all settings to gd, overwriting them. This param overrides the values of the other params. Default is FALSE. |
do_addins , do_editor_bindings , do_rstudio_bindings
|
booleans, if TRUE will push the respective file. Default is FALSE |
progBar |
function, designed to work with [progress_bar()]. Runs after each file is pushed. |
nothing
mimic_on() push() # does nothing push(do_all = TRUE) # will push all settings to gd, overwriting them push(do_editor_bindings = FALSE, do_rstudio_bindings = FALSE) # will push only editor and rstudio bindings mimic_off()
mimic_on() push() # does nothing push(do_all = TRUE) # will push all settings to gd, overwriting them push(do_editor_bindings = FALSE, do_rstudio_bindings = FALSE) # will push only editor and rstudio bindings mimic_off()
This is a helper function for [pull()] and [sync()] that: * reads a json file from Google Drive inside the rstudio folder * converts it to a data frame (to resolve conflicts in the future)
read_from_gd(what, progBar = NULL)
read_from_gd(what, progBar = NULL)
what |
One of c("rstudio_bindings", "editor_bindings", "addins"), the file to read |
progBar |
function, designed to work with [progress_bar()]. Runs after the file is read. |
A data frame with the contents of the file, converted from json
[read_from_local()] [sync()] [jsonlite::fromJSON()] [googledrive::drive_read_string()]
mimic_on() read_from_gd("rstudio_bindings") read_from_gd("editor_bindings") read_from_gd("addins") mimic_off()
mimic_on() read_from_gd("rstudio_bindings") read_from_gd("editor_bindings") read_from_gd("addins") mimic_off()
This is a helper function for [sync()] that: * reads a json file from the local rstudio folder * converts it to a data frame (to resolve conflicts in the future)
read_from_local(what)
read_from_local(what)
what |
One of c("rstudio_bindings", "editor_bindings", "addins"), the file to read |
A data frame with the contents of the file, converted from json
[read_from_gd()], [push()], [sync()], [jsonlite::read_json()]
mimic_on() read_from_local("rstudio_bindings") read_from_local("editor_bindings") read_from_local("addins") mimic_off()
mimic_on() read_from_local("rstudio_bindings") read_from_local("editor_bindings") read_from_local("addins") mimic_off()
Get rstudio local path
rstudio_path()
rstudio_path()
path to rstudio local
[rappdirs::user_config_dir()], [is_windows()], [usethis::is_windows()]
rstudio_path()
rstudio_path()
Gets the settings from Google Drive and from the local files, and merges them. If there are conflicts, will ask the user to resolve them. Finally, will write the merged settings to the local files, and push them to Google Drive. Will first ask for confirmation if interactive. This function is what's called by the addin.
sync(write = NULL, useProgBar = TRUE)
sync(write = NULL, useProgBar = TRUE)
write |
boolean, if TRUE will write the merged settings to the local files, and push them to Google Drive. FALSE essentially just makes conflict resolution, without changing any files (basically a dry run). If a value other than NULL is provided, this will skip confirmation. |
useProgBar |
boolean, if TRUE will show a progress bar. Default is TRUE. |
NOTE: if it's not interactive, it won't write to files because of CRAN policies.
nothing
[push()], [pull()]
mimic_on() if(interactive()) { sync(write = TRUE) # will immediately try to sync all settings sync(write = FALSE) # dry run, will not write to files or push to gd sync() # will ask for confirmation, then sync all settings } mimic_off()
mimic_on() if(interactive()) { sync(write = TRUE) # will immediately try to sync all settings sync(write = FALSE) # dry run, will not write to files or push to gd sync() # will ask for confirmation, then sync all settings } mimic_off()