Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping alias commands in a gitconfig files

Tags:

git

git-config

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
like image 958
nickf Avatar asked Oct 18 '11 08:10

nickf


1 Answers

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
like image 134
VonC Avatar answered Sep 21 '22 07:09

VonC