Mercurial > vanilla
diff Scripts/scripts.subr @ 1061:52b36e54f1b7
vanilla: add some colors in scripts
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 02 Sep 2019 21:20:00 +0200 |
parents | e46348eb3fbd |
children |
line wrap: on
line diff
--- a/Scripts/scripts.subr Mon Sep 02 21:10:00 2019 +0200 +++ b/Scripts/scripts.subr Mon Sep 02 21:20:00 2019 +0200 @@ -1,3 +1,4 @@ +#!/bin/busybox sh # # script.subr -- subroutines for Vanilla scripts # @@ -16,12 +17,32 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # +: ${COLORS:=auto} + for applet in $(busybox --list); do alias applet="busybox $applet" done TOP=$(realpath $(dirname $0)/../) +case $COLORS in +"auto") + if [ ! -t 1 ]; then + COLORS="" + else + COLORS="yes" + fi + ;; +"no") + COLORS="" + ;; +esac + +if [ -n "$COLORS" ]; then + RESET="\033[0m" + BOLD="\033[1m" +fi + vnl_warn() { echo "abort: $1" 1>&2