1

I have an alias I want to use with code-maat and don't know how to do so where I can add the after when I run the alias. is this possible? For example, here is what I want to alias:

alias gmaat = 'git log --pretty=format:"[%h] %an %ad %s" --date=short --numstat --after=YYYY-MM-DD'

So what I need to do is have it when I run the gmaat alias, I either would be prompted to add the --after date or I would run

gmaat YYYY-MM-DD // filling in the date

If this is possible I appreciate in advance help that can be given.

EDIT

I tried the first answer below by adding this:

alias gmaat='!f() { git log --pretty=format:"[%h] %an %ad %s" --date=short --numstat --after=$1 }; f'

When I run this and add the date after the alias I get this error:

fatal: ambiguous argument '2014-11-01': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
pertrai1
  • 4,146
  • 11
  • 46
  • 71

1 Answers1

0

You can use a positional parameter:

git config alias.gmaat '!f() { git log --pretty=format:"[%h] %an %ad %s" --date=short --numstat --after=$1; }; f'

Note the ';' inside the { xxx; }

That way, you can pass YYYY-MM-DD as a parameter

git gmaat YYYY-MM-DD // filling in the date

Without using git config alias, you would then need to define in your ~/.bashrc_profile a function:

gmaatf() { git log --pretty=format:"[%h] %an %ad %s" --date=short --numstat --after=$1 }

Then:

 alias gmaat=gmaatf
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250