Skip to content

Instantly share code, notes, and snippets.

@erkarp
Last active June 16, 2016 13:42
Show Gist options
  • Save erkarp/73137d51d38562160ae0 to your computer and use it in GitHub Desktop.
Save erkarp/73137d51d38562160ae0 to your computer and use it in GitHub Desktop.

Revisions

  1. erkarp revised this gist Jun 16, 2016. No changes.
  2. erkarp revised this gist Jun 11, 2016. 1 changed file with 4 additions and 22 deletions.
    26 changes: 4 additions & 22 deletions gitlog
    Original file line number Diff line number Diff line change
    @@ -1,28 +1,10 @@
    # Use function 'datecode' (with optional date arg yyyy-mm-dd)
    # Copy returned string as arg with function 'gitlog'
    # Other optional args: short/long, -n

    gitlog() {
    command='git log '
    for var in "$@"
    do
    argument=$(check-arg $var)
    command=$command$argument
    done
    echo $command
    $command
    c="git log --all --decorate --graph --pretty=format:%C(Yellow)%h%Creset_%Cred%cd%Creset_%Cblue%s%Creset%C(magenta)%d%Creset --date=local"
    $c
    }

    check-arg() {
    case "$@" in
    short) echo ' --pretty=format:%Cblue%s%Creset'
    ;;
    long) echo ' --pretty=format:%C(Yellow)%h%Creset_%Cred%cd%Creset_%Cblue%s%Creset%C(magenta)%d%Creset --date=local'
    ;;
    -*) echo " $1"
    ;;
    esac
    }

    # Use function 'datecode' (with optional date arg yyyy-mm-dd)

    datestamp() {
    date +"%Y-%m-%d"
  3. erkarp revised this gist Dec 24, 2015. 1 changed file with 13 additions and 4 deletions.
    17 changes: 13 additions & 4 deletions gitlog
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    # Use function 'datecode' (with optional date arg yyyy-mm-dd)
    # Copy returned string as arg with function 'gitlog'
    # Other optional args: short/long, -n

    gitlog() {
    command='git log '
    #if $1 ==
    for var in "$@"
    do
    argument=$(check-arg $var)
    @@ -11,10 +14,7 @@ gitlog() {
    }

    check-arg() {
    z=':'
    case "$@" in
    [0-9]**) echo --after=\"$1 00:00\"
    ;;
    short) echo ' --pretty=format:%Cblue%s%Creset'
    ;;
    long) echo ' --pretty=format:%C(Yellow)%h%Creset_%Cred%cd%Creset_%Cblue%s%Creset%C(magenta)%d%Creset --date=local'
    @@ -26,4 +26,13 @@ check-arg() {

    datestamp() {
    date +"%Y-%m-%d"
    }
    datecode() {
    if [[ $1 =~ [0-9] ]]
    then
    echo "--after='$1 00:00' --before='23:59'"
    else
    echo $1
    echo "--after='$(datestamp) 00'"
    fi
    }
  4. erkarp renamed this gist Dec 24, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. erkarp created this gist Dec 24, 2015.
    29 changes: 29 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    gitlog() {
    command='git log '
    #if $1 ==
    for var in "$@"
    do
    argument=$(check-arg $var)
    command=$command$argument
    done
    echo $command
    $command
    }

    check-arg() {
    z=':'
    case "$@" in
    [0-9]**) echo --after=\"$1 00:00\"
    ;;
    short) echo ' --pretty=format:%Cblue%s%Creset'
    ;;
    long) echo ' --pretty=format:%C(Yellow)%h%Creset_%Cred%cd%Creset_%Cblue%s%Creset%C(magenta)%d%Creset --date=local'
    ;;
    -*) echo " $1"
    ;;
    esac
    }

    datestamp() {
    date +"%Y-%m-%d"
    }