You can do this with a single grep instruction, using Perl mode and \K
to reset the match buffer, so you get only the branch name.
$ git branch | grep -oP "^\*\s+\K\S+$"
master
You can do this with a single grep instruction, using Perl mode and \K
to reset the match buffer, so you get only the branch name.
$ git branch | grep -oP "^\*\s+\K\S+$"
master