Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save virajkulkarni14/3c002c7fbdc4e9b25d2a56ae2279c75f to your computer and use it in GitHub Desktop.
Save virajkulkarni14/3c002c7fbdc4e9b25d2a56ae2279c75f to your computer and use it in GitHub Desktop.

Revisions

  1. @oshybystyi oshybystyi created this gist Jun 10, 2015.
    31 changes: 31 additions & 0 deletions git-auto-status.plugin.zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #
    # Run git status after specified set of command
    #
    # @author Oleksandr Shybystyi [email protected]
    #

    # default list of git commands `git status` is running after
    gitPreAutoStatusCommands=(
    'add'
    'rm'
    'reset'
    'commit'
    'checkout'
    'mv'
    'init'
    )

    # taken from http://stackoverflow.com/a/8574392/4647743
    function elementInArray() {
    local e
    for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
    return 1
    }

    function git() {
    command git $@

    if (elementInArray $1 $gitPreAutoStatusCommands); then
    command git status
    fi
    }