Last active
February 22, 2024 13:04
-
-
Save francisbarton/2e32b4b5317341d27d977544993ca0c5 to your computer and use it in GitHub Desktop.
My .Rprofile
This file contains 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
options( | |
usethis.full_name = "Fran Barton", | |
usethis.protocol = "ssh", | |
usethis.description = list( | |
`Authors@R` = 'person( | |
"Fran", "Barton", | |
email = "francis.barton@nuh.nhs.uk", | |
role = c("aut", "cre"), | |
comment = c(ORCID = "0000-0002-5650-1176") | |
)', | |
Version = "0.0.1", | |
License = "MIT + file LICENSE" | |
), | |
conflicts.policy = list( | |
warn = FALSE, | |
can.mask = c("stats", "tibble", "rlang", "graphics") | |
), | |
install.packages.check.source = "no", | |
install.packages.compile.from.source = "interactive", | |
continue = " ", | |
available.browse = FALSE, | |
vsc.use_httpgd = TRUE, | |
vsc.rstudioapi = TRUE, | |
xfun.pkg_attach.message = FALSE, | |
repos = c( | |
bristol_cran = "https://www.stats.bris.ac.uk/R/", | |
diego_hernan = "https://dieghernan.r-universe.dev", | |
miles_mcbain = "https://milesmcbain.r-universe.dev", | |
garrickadenb = "https://gadenbuie.r-universe.dev", | |
janthemarvin = 'https://janmarvin.r-universe.dev', | |
lvaudor_univ = "https://lvaudor.r-universe.dev" | |
), | |
dh_modular_sql_path = file.path("~/Documents/R Projects/fh-modular-sql/") | |
) | |
if (interactive()) { | |
# options that only make sense in interactive conditions | |
options( | |
# superfluous as TRUE by default but just putting in for reference | |
reprex.tidyverse_quiet = TRUE, | |
usethis.quiet = FALSE, | |
# prompt = "\u13D2_\u3009 " | |
prompt = "[R]> ", | |
paint_remind_mask_print = FALSE | |
) | |
paint::mask_print() | |
# some variables that myrmidon::myr_prompt_*() can use | |
.myr_prompt_env <- rlang::new_environment( | |
data = list( | |
# time when R session started (ie when .Rprofile called) | |
start_time = Sys.time(), | |
moon_phase = suncalc::getMoonIllumination()$phase, | |
myr_prompt_col1 = "whitesmoke", | |
myr_prompt_col2 = "orange", | |
myr_prompt_col3 = "darkseagreen1" | |
) | |
) | |
# Trying to get RStudio info at R start, | |
# but it's all too soon... | |
# https://github.com/rstudio/rstudio/issues/1579#issuecomment-495706255 | |
# # setHook("rstudio.sessionInit", function(newSession) { | |
# # if (newSession) { | |
# # rstd <- rstudioapi::versionInfo()$release_name | |
# # message("Welcome to ", rstd) | |
# # } | |
# # }, action = "append") | |
# # https://github.com/r-lib/sessioninfo/blob/59e1b11a022bac38ea316e4c52f20dfdb72f1b4e/R/platform-info.R#L45 | |
# # rstd <- rstudioapi::versionInfo()$release_name | |
# # rstd <- RStudio.Version()$release_name | |
suppressPackageStartupMessages({ | |
require(usethis) | |
require(gert) | |
require(myrmidon) | |
require(remotes) | |
require(clipr) | |
}) | |
.First <- function() { | |
Sys.setenv(LANG = "en_GB.UTF-8") | |
suppressWarnings(Sys.setlocale("LC_ALL", Sys.getenv("LANG"))) | |
nuh_colours <- c( | |
"#cd438f", # pink | |
"#fb8998", # pink overlap (subsidiary) | |
"#fda13d", # orange | |
"#06babc", # blue overlap (subsidiary) | |
"#00a7dd", # blue | |
"#06babc", # blue overlap (subsidiary) | |
"#88c23d" # green | |
) | |
nuh_colour_bar <- function(col_vec = nuh_colours) { | |
col_vec |> | |
lapply(crayon::make_style) |> | |
mapply( | |
c(12, 8, 12, 8, 12, 8, 12), | |
FUN = \(x, y) x(paste0(rep("\u2583", y), collapse = ""))) |> | |
paste0(collapse = "") | |
} | |
cat("\014") # clear console | |
cat(paste(nuh_colour_bar(), "\n\n")) | |
cat( | |
crayon::style( | |
paste0( | |
crayon::style("π NOTTINGHAM ", nuh_colours[[1]]), | |
crayon::style("UNIVERSITY ", nuh_colours[[2]]), | |
crayon::style("HOSPITALS ", nuh_colours[[3]]), | |
crayon::style("NHS ", nuh_colours[[5]]), | |
crayon::style("TRUST: ", nuh_colours[[7]]), | |
crayon::style("We Listen, ", nuh_colours[[4]]), | |
crayon::style("We Care ", nuh_colours[[5]]), | |
"π\n\n"), | |
"bold")) | |
cli::cli_alert(paste0(R.version.string, " '", R.version[["nickname"]], "'")) | |
cli::cli_alert(paste("Running under", utils::osVersion)) | |
# cli::cli_alert(paste("Welcome to RStudio", rstudioapi::versionInfo()[["version"]], rstudioapi::versionInfo()[["release_name"]])) | |
new_pkgs <- unname(utils::old.packages(type = "binary")[, "Package"]) | |
new_pkgs_len <- ifelse(!is.null(new_pkgs), length(new_pkgs), 0) | |
conflicted::conflict_prefer("filter", "dplyr", quiet = TRUE) | |
conflicted::conflict_prefer("lag", "dplyr", quiet = TRUE) | |
conflicted::conflict_prefer("Position", "ggplot2", quiet = TRUE) | |
conflicted::conflict_prefer("git_credentials", "usethis", quiet = TRUE) | |
conflicted::conflict_prefer("install_github", "remotes", quiet = TRUE) | |
conflicted::conflict_prefer("italic", "flextable", quiet = TRUE) | |
if (new_pkgs_len > 0) { | |
cli::cli_alert( | |
paste( | |
"Updates available for:", | |
paste0(new_pkgs, collapse = ", ") | |
) | |
) | |
} | |
# cli::cli_alert(tryCatch(myrmidon::random_tube_route(), error = \(e) NULL)) | |
dww <- myrmidon::get_daily_welsh_word() | |
if (nzchar(dww[["item_def"]]) & !is.na(dww[["item_def"]])) { | |
cli::cli_alert(dww[["item_def"]]) | |
# cli::cli_alert(dww[["item_des"]]) | |
} | |
phrase <- sample(c( | |
"Good luck! π€", | |
"It's the best we could do π€·", | |
"Just blame them for everything π", | |
"No pressure then π", | |
"They will guide you π§", | |
"Name your variables wisely π", | |
"Rubber-ducking can be really helpful *nudge* π¦", | |
"Remember to move and take a walk sometimes πΆοΈ", | |
"There are other drinks besides coffee, you know β", | |
"(It's weird, but) they're a big fan of yours π€©", | |
"Ignore them and get on with your work π©π»βπ»", | |
"Don't forget to do incremental git commits! π§±", | |
"They are here to advocate for Future You π", | |
"You had better be on your best behaviour π", | |
"Your typos are still your problem, though π", | |
"Hmmmmmmmmmm π€", | |
"Well, you can always refresh and try again π€¨", | |
"They have trained for this moment π±βπ€" | |
), 1) | |
project_mascot_data <- myrmidon::project_mascot(alliterative = FALSE) | |
cli::cli_alert(paste0( | |
"Your session mascot is ", | |
glue::glue_data( | |
project_mascot_data, | |
"{mascot_name} the {mascot_label} {mascot_emoji}" | |
), | |
"... ", | |
phrase | |
)) | |
cat(paste(nuh_colour_bar(), "\n\n")) | |
myrmidon::myr_prompt_light() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment