Skip to content

Instantly share code, notes, and snippets.

@skeggse
Created February 27, 2018 18:28
Show Gist options
  • Save skeggse/8f7c856a8aac7097122fa4531dce7ad9 to your computer and use it in GitHub Desktop.
Save skeggse/8f7c856a8aac7097122fa4531dce7ad9 to your computer and use it in GitHub Desktop.

Revisions

  1. skeggse created this gist Feb 27, 2018.
    30 changes: 30 additions & 0 deletions wdiff.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #!/bin/bash

    INTERVAL=1

    afile="$(mktemp)"
    bfile="$(mktemp)"

    function show_diff() {
    a="$1"
    b="$2"
    diff="$(git diff --no-index --color "$b" "$a" | tail -n +5)"
    if [[ "$diff" != '' ]]; then
    date
    echo "$diff"
    fi
    }

    "$@" | tee "$bfile"
    echo

    while true; do
    sleep 1
    "$@" > "$afile"
    show_diff "$afile" "$bfile"
    sleep 1
    "$@" > "$bfile"
    show_diff "$bfile" "$afile"
    done

    rm "$afile" "$bfile"