blob: 4d89c27701046b272e562f5b234c9d792f8ff1e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
|