Show difference from previous line
Opened this issue · 7 comments
I'm starting to become more than a basic hl user and the config I have in mind is to highlight what is different from the line above. The idea is to compare from delimiter to delimiter a line with the line above it, and when a diff is detected, that "cell" is colored as well as the rest of the line, even if later cells are the same as previous. Here's an example I mocked up in an RTF editor:
Hello,
interesting functionality ... Let me think about it.
Hello,
interesting functionality ... Let me think about it.
Great news! FYI: I asked over on r/commandline if there was a tool that did just this and I got a few code snippets in response but no dedicated tool.
In case you're curious:
https://www.reddit.com/r/commandline/comments/sq1y3o/diff_for_single_file_showing_changes_from
Here is just a small modification of the AWK script found on reddit, that alternates colors :
#/bin/bash
awk 'BEGIN {
FS = OFS = ",";
if (getline == 1) {
print;
}
split($0, previous);
idx_color = 0;
}
{
current = $0;
for (i=1; i<=NF; i++) {
if ($i != previous[i]) {
$i = sprintf("\033[3%dm%s", 1 + idx_color, $i);
break;
}
}
print $0 "\033[0m";
split(current, previous);
idx_color = (idx_color + 1) % 4;
}' "$1"
I'm thinking about how to implement a more generic solution in hl. But sorry, I have other options to implement in hl before that one.
Any plans to support this natively?
Hello,
I have some other functionalities to implement in "hl", in "RPN", and in other projects. I have many technical articles to write for Linux magazines, and a lot of other things to do, and I only work on these projects during my free time (week-ends and holidays). Things would go much faster if I were paid for these developments and if I could work on them at full time, but no one currently supports me financially, so as this functionality doesn't have a high priority in my tasks list and a solution exists with a script, I don't think I could implement it soon.
Thank you for the awesome tool and hard work. I use it everyday
Thank you for your comment !
I'm glad to see that this tool is useful. I'd like to do more, but sometimes I need to sleep ... ;-)