prompt icon indicating copy to clipboard operation
prompt copied to clipboard

Show git branch

Open eddelbuettel opened this issue 8 years ago • 1 comments

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

image

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/}")"
}

eddelbuettel avatar Jan 14 '18 21:01 eddelbuettel

That'd be nice.

Perhaps something like this, not tested enough I guess.

> sub( "On branch ", "", system( "git status", intern = TRUE )[1] )
[1] "master"

romainfrancois avatar Mar 25 '18 11:03 romainfrancois