summaryrefslogtreecommitdiffstats
path: root/hl_bin/diff
diff options
context:
space:
mode:
authormbornet-hl <mbornet.pro@wanadoo.fr>2015-10-01 09:49:18 +0200
committermbornet-hl <mbornet.pro@wanadoo.fr>2015-10-01 09:49:18 +0200
commitd30cc1b038ba54458e302df377aee5dcc28db1c8 (patch)
treeac91bb4c57a9f691541885bed9f297369ebf19c6 /hl_bin/diff
parent2c6a0b03d4d1c6d05cb39f55e3d2181723a460e6 (diff)
downloadhl-d30cc1b038ba54458e302df377aee5dcc28db1c8.zip
hl-d30cc1b038ba54458e302df377aee5dcc28db1c8.tar.gz
hl-d30cc1b038ba54458e302df377aee5dcc28db1c8.tar.bz2
Added hl_bin directory
Diffstat (limited to 'hl_bin/diff')
-rwxr-xr-xhl_bin/diff41
1 files changed, 41 insertions, 0 deletions
diff --git a/hl_bin/diff b/hl_bin/diff
new file mode 100755
index 0000000..4d89c27
--- /dev/null
+++ b/hl_bin/diff
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Script for command output colorization
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# @(#) [MB] cr_hl_generic Version 1.7 du 15/09/26 -
+#
+# This script call the original programme with all the arguments
+# it received, and pipe it to "hl" using its name as the "hl"
+# configuration.
+#
+# In case the user doesn't want the output of the command to
+# be colorized, the following syntax must be used :
+# USE_HL=no cmd [args ...]
+#
+
+case "$USE_HL" in
+ n|N|no|NO|0) USE_HL="no"
+ ;;
+esac
+
+progname="$(basename $0)"
+pathname="$(type -p "$progname")"
+dirname="$(dirname "$pathname")"
+
+PATH="$(echo "$PATH" | sed "s|^$dirname:||;s|:$dirname:|:|g")"
+export PATH
+
+if [ "$USE_HL" = "no" ]; then
+ # No colorization
+ # ~~~~~~~~~~~~~~~
+ "$progname" "$@"
+ rc=$?
+else
+ # Default behaviour : colorization
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ "$progname" "$@" | hl --"$progname"
+ rc=${PIPESTATUS[0]}
+fi
+
+exit $rc