commit 4a9c7366469f8ea50ec6de562012e35c76b3dff9
parent 3eb0e42a8b3793801524ef538ee1ae8345f3c639
Author: clamiax <smoppy@gmail.com>
Date: Fri, 23 Oct 2015 20:26:49 +0200
[diffmon] new script
Diffstat:
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -132,3 +132,8 @@ like this:
```
{ MODKEY|ShiftMask, XK_o, spawn, SHCMD("mimeopen -n \"$(/path/of/browse)\"") },
```
+
+diffmon
+-------
+Simple script which monitor a file and show lines that are changed since you
+ran it.
diff --git a/diffmon b/diffmon
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Monitor a file and show changed lines.
+
+file="$1"
+
+if [ -z "$1" ]; then
+ echo "Usage: $0 <file>"
+ exit 1
+fi
+
+copy="$(mktemp -u /tmp/rummage.XXXXX)"
+cp "$file" "$copy"
+
+trap "rm -f '$copy'; exit 1" EXIT INT TERM HUP # cleanup
+watch diff --old-line-format='' --new-line-format='%L' --unchanged-line-format='' "$copy" "$file"