nickf
nickf

Reputation: 546035

Escaping alias commands in a gitconfig files

I'm trying to add an alias command to my gitconfig file and it reports "bad config file" on the line I've added. I suspect it's something to do with the sed command and some escaping issues, but I don't know exactly what it's supposed to be. Here's the command, with linebreaks added for legibility:

impact = !git ls-files -z
       | xargs -0n1 git blame -w -C
       | sed -r 's/^[^(]+\((.*) [0-9]{4}-.*/\1/'
       | sed -r 's/ +$//'
       | sort -f
       | uniq -c
       | sort -nr

Upvotes: 10

Views: 2689

Answers (1)

VonC
VonC

Reputation: 1323953

I suspect it is more about the '\', which needs to be doubled.

I tried your alias with '\\' without any error message.

impact = !git ls-files -z
       | xargs -0n1 git blame -w -C
       | sed -r 's/^[^(]+\\((.*) [0-9]{4}-.*/\\1/'
       | sed -r 's/ +$//'
       | sort -f
       | uniq -c
       | sort -nr

Upvotes: 15

Related Questions