Created
September 29, 2021 21:38
-
-
Save jthomasmock/22e851343f31203170547144ff35e8e1 to your computer and use it in GitHub Desktop.
An example of customizing your R prompt with the RProfile.
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
.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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you should also mention that you need the emo library to have this work. I found it online and installed it.