diffutils-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

diff: get color option from program_name


From: Alireza Arzehgar
Subject: diff: get color option from program_name
Date: Sun, 4 Dec 2022 14:16:34 +0330

I suggest new feature to enable color by program name. Some projects
implemented this feature linke mkfs.x and kvm alias of qemu-system-x86_64.
colorediffs <https://github.com/Qeole/colorediffs> developed for lack of
this feature on GNU diffutils.
Users can link or copy diff to colorediff and after running it, they can see
colored diffs.

Bests,
Alireza

From: alireza <alirezaarzehgar82@gmail.com>
Date: Sun, 4 Dec 2022 14:11:20 +0330
Subject: [PATCH] diff: get color option from program_name

Assign always to colors_style if program name is equal to colorediff.

Signed-off-by: alireza <alirezaarzehgar82@gmail.com>
---
 src/diff.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/diff.c b/src/diff.c
index 9938daa..d2c706b 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -660,6 +660,10 @@ main (int argc, char **argv)
       prev = c;
     }

+  size_t prfxlen = strlen(program_name) - 10;
+  if (prfxlen >= 0 && STREQ(program_name + prfxlen, "colorediff"))
+    specify_colors_style("always");
+
   if (colors_style == AUTO)
     {
       char const *t = getenv ("TERM");
-- 
2.30.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]