-
-
Save sbalci/e5b2c0a7545b04d543b8abe620a56052 to your computer and use it in GitHub Desktop.
Check for open RStudio Projects that have the same name (macOS only for now)
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
check_rproj_dupes <- function() { | |
os <- .Platform$OS.type | |
if (os == "unix") { | |
ps_out <- system("ps -e", intern = TRUE) | |
ps_rproj <- ps_out[grepl(".Rproj", ps_out)] | |
ps_split <- strsplit(ps_rproj, "\\s") | |
rproj_paths <- lapply(ps_split, function(x) x[grepl(".Rproj$", x)]) | |
rproj_basenames <- lapply(rproj_paths, basename) | |
rproj_dupes <- unlist(rproj_basenames[duplicated(rproj_basenames)]) | |
} | |
if (os == "windows") { | |
stop("Sorry, check_rproj_dupes() doesn't work on Windows yet :-(") | |
} | |
if (length(rproj_dupes) > 0) { | |
warning( | |
"You've got open RStudio Projects with the same name:\n", | |
paste("-", rproj_dupes, collapse = "\n"), | |
call. = FALSE | |
) | |
} | |
} | |
check_rproj_dupes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment