Skip to content

Instantly share code, notes, and snippets.

@lincerely
Created December 8, 2020 15:21
Show Gist options
  • Save lincerely/1dc0756428fd11758c6b1db7408dd26b to your computer and use it in GitHub Desktop.
Save lincerely/1dc0756428fd11758c6b1db7408dd26b to your computer and use it in GitHub Desktop.
#!/usr/local/plan9/bin/rc
. 9.rc
. $PLAN9/lib/acme.rc
if(~ $#* 0 1){
echo >[1=2] usage: adiff file1 file2
echo >[1=2] or adiff file1 file2... dir
exit usage
}
newwindow
l=$1
r=$2
if (test -d $1) l=$1/`{basename $2}
if not if (test -d $2) r=$2/`{basename $1}
9 echo 'name '^`{pwd}^/-diff-^`{basename $l} | winwrite ctl
9 diff $* | 9 awk -v 'l='$l -v 'r='^$r '/^diff/ {l=$2; r=$3; next} /^[1-9]/ {sub("[acd]", " & " r ":"); sub("^", l ":", $0)}
{print $0}' | winwrite body
winctl clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment