2020-12-29 08:38:07 -08:00
|
|
|
#!/usr/bin/env sh
|
2021-07-29 00:37:35 -07:00
|
|
|
# YES_ZSH
|
2021-07-29 05:44:12 -07:00
|
|
|
# YES_BASH
|
|
|
|
# YES_DASH
|
2021-09-23 06:48:05 -07:00
|
|
|
# YES_ASH
|
2021-10-04 17:06:45 -07:00
|
|
|
# YES_BB_AWK
|
2021-07-29 00:37:35 -07:00
|
|
|
|
2021-07-30 19:41:16 -07:00
|
|
|
similar() { ### @-
|
2021-08-01 09:27:25 -07:00
|
|
|
### highlight adjacent lines up to the first inequivalent character.
|
2021-07-29 05:44:12 -07:00
|
|
|
[ $# -eq 0 ] || { printf "%s\n" "$0: does not take arguments" >&2; return 1; }
|
2021-07-29 00:37:35 -07:00
|
|
|
awk '
|
|
|
|
{
|
|
|
|
i=0
|
2021-10-01 12:00:23 -07:00
|
|
|
for(c=1;c<length;c++)
|
|
|
|
if(substr($0,c,1)==substr(L,c,1)) i++
|
2021-07-29 00:37:35 -07:00
|
|
|
else break
|
|
|
|
#print substr($0,1,i) "\033[7m" substr($0,i+1) "\033[0m"
|
|
|
|
print "\033[31m" substr($0,1,i) "\033[0m" substr($0,i+1)
|
|
|
|
L=$0
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
2021-08-02 13:48:46 -07:00
|
|
|
[ -n "${preload+-}" ] || similar "$@"
|