From 381f772e05102fbd12b59bcc9aea4d2c88b92f17 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 4 Apr 2018 19:20:49 +0900 Subject: renamed colored printers in bashrc and factorized function to print final line --- bashrc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bashrc b/bashrc index b4704bf..02e6b5f 100644 --- a/bashrc +++ b/bashrc @@ -123,20 +123,29 @@ export LS_COLORS='di=94:ln=96:or=96;41:so=0:pi=0:ex=01;92:bd=0;42:cd=0;42:su=0:s #}}} #{{{ colored printers - function info() { +function pline() { + local col=$1 + local tag=$2 + local msg=$3 + echo -e "$col[$tag]: $msg${BCol_NoColor}" +} + function pinfo() { local msg=$1 - echo -e "${BCol_BrightGreen}[INFO]: ${msg}${BCol_NoColor}" + local tag=${2:-INFO} + pline ${BCol_BrightGreen} $tag ${msg} } - function warn () { + function pwarn () { local msg=$1 - echo -e "${BCol_YellowOrange}[WARN]: ${msg}${BCol_NoColor}" + local tag=${2:-WARN} + pline ${BCol_YellowOrange} $tag ${msg} } - function err() { + function perr() { local msg=$1 local exit=${2:-exit} - echo -e "${BCol_BrightRed}[ERR]: ${msg}${BCol_NoColor}" + local tag=${3:-ERR} + pline ${BCol_BrightRed} $tag ${msg} [[ "$exit" == "exit" ]] && exit 1 || return 0 } -- cgit v1.2.3