Skip to content

Instantly share code, notes, and snippets.

@jthomasmock
Created September 29, 2021 21:38
Show Gist options
  • Save jthomasmock/22e851343f31203170547144ff35e8e1 to your computer and use it in GitHub Desktop.
Save jthomasmock/22e851343f31203170547144ff35e8e1 to your computer and use it in GitHub Desktop.
An example of customizing your R prompt with the RProfile.
.First <- function(){
# adapted from: https://lapsedgeographer.london/2020-11/custom-r-prompt/
my_prompt <- function(...) {
git_branch <- suppressWarnings(system("git rev-parse --abbrev-ref HEAD",
ignore.stderr = TRUE, intern = TRUE))
if (length(git_branch) != 0) {
git_msg <- paste0(" @", git_branch)
} else {
git_msg <- ""
}
console_msg <- glue::glue(
"[{format(Sys.time(), '%H:%M')} {emo::ji('computer')}",
"{git_msg}]> "
)
options(prompt = console_msg)
invisible(TRUE)
}
my_prompt()
addTaskCallback(my_prompt)
}
@jekylls
Copy link

jekylls commented Jan 3, 2024

you should also mention that you need the emo library to have this work. I found it online and installed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment