79278755

Date: 2024-12-13 15:14:38
Score: 1.5
Natty:
Report link

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.

Reasons:
  • Blacklisted phrase (1): Is there a way
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Nils