tags:

views:

73

answers:

3

I'd like git status to always use the short format:

$ git status --short
 M src/meck.erl
 M test/meck_tests.erl
?? erl_crash.dump
?? meck_test_module.coverdata

There does not seem to exist a configuration option for this, and git config --global alias.status "status --short" does not work. I haven't managed to create and alias in zsh either.

How can I make git status to use the short format by default.

A: 

You may create an alias.

But I'd create bash script:

#!/bin/bash
git status --short

save this script in ~/bin/gits (or /usr/bin/gits and chmod 555), so typing gits gives what you want.

takeshin
I would prefer not to depend on any local aliases and instead use the default `git status`.
Adam Lindberg
+3  A: 

Use a different alias. Instead of trying to alias 'status', do:

git config --global alias.s 'status --short'

Now "git s" gives you short output, and "git status" gives you long output.

William Pursell
That is what I suggested in my comment.
Lucas
This is what I ended up doing. Thanks.
Adam Lindberg
+1  A: 

The easiest way is to use another alias, as I suggest in my comment. I think there is no way to create an alias with the name of a built-in command. If you insist on using git status, another option is (git is open source after all):

  • get the git source code (e.g. http://github.com/git/git/)
  • open the file builtin/commit.c
  • look for the function int cmd_status(int argc, const char **argv, const char *prefix)
  • at the bottom you find a switch-statement
  • comment out the two lines as shown in the following code
  • add the line as in the following code

code:

...
switch (status_format) {
    case STATUS_FORMAT_SHORT:
        wt_shortstatus_print(&s, null_termination);
        break;
    case STATUS_FORMAT_PORCELAIN:
        wt_porcelain_print(&s, null_termination);
        break;
    case STATUS_FORMAT_LONG:
        //s.verbose = verbose;      <--lines have to be commented out
        //wt_status_print(&s);
        wt_shortstatus_print(&s, null_termination);    //<-- line has to be added
        break;
    } 
 ...
  • remake git
Lucas
Awesome! Bonus vote for referencing the source code!
Adam Lindberg