prompt
prompt copied to clipboard
Show git branch
I have long used a (shell) prompt that clearly display which git branch I am on, and that has saved my bacon multiple times:

If I were to change my R prompt -- and not yet sure I would as I find the command-line more central for "basic operations" I would not do in R via ESS or RStdudio -- I would want to see that too. In the shell, it uses this bash functions you should be able to replicate using one of the git interfaces:
## Set the prompt to show the current git branch:
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
That'd be nice.
Perhaps something like this, not tested enough I guess.
> sub( "On branch ", "", system( "git status", intern = TRUE )[1] )
[1] "master"