I'm trying to make a git alias that shows branch names and descriptions. There is no dedicated command or switch to get the description of a branch; it must be sussed from configuration. However I want to get a list of all branches and their descriptions (if they have one).
One can get a sort of "raw data" like so:
$ git config -l
core.symlinks=false
core.autocrlf=false
core.fscache=true
color.diff=auto
So the entries that I'm interested in look like this:
branch.featureA.description=Mail templates
branch.featureB.description=Something else
Which I can get with this pipeline: git config -l | grep description | grep \^branch.
For my desired output, I want this:
featureA Mail templates
featureB Something else
So one way to express this is that I want the second "column" after the period, and the first "column" after the equal sign. Or, I want .branchname.
and .description=
removed. I'm not sure the best way to go, but I tried using awk
to treat the string as columns. I can get part of what I want with different delimiters:
$ git config -l | grep description | grep \^branch. | awk -F '.' '{ print $2 }'
featureA
featureB
$ git config -l | grep description | grep \^branch. | awk -F '=' '{ print $2 }'
Mail Templates
Something else
However trying to combine the two delimiters doesn't seem to work:
$ git config -l | grep description | grep \^branch. | awk -F '.=' '{ print $2 }'
Mail templates
Something else
How can I parse the data I want out of the string?