jthill's nice sed answer pointed me in the right direction to implement the same solution but in awk (more portable and more readable for me, I don't have GNU sed)
git branch --color=always | awk '/^\*/ {print} !/^\*/ {lines[n++] = $0} END {for ( i = 0; i < n; i++ ) print lines[i]}'
I'm a bit dissatisfied with how long the awk script is for something so simple.
Now I also would like to make this work with columns, like git branch --column
.
I can do that just by piping to git column --mode=auto
.
git branch --color=always | awk ... | git column --mode=auto
This isn't a perfect answer for me, because it won't change the default behaviour of git branch
.
Is there a way to override what git branch
without any arguments will do?
I don't want to have to change my decades of muscle memory just to start using an alias. IMO, there should be a config parameter for this and I'm surprised there isn't.