Moved ansi colour definitions into a function so they can be turned back on after calling noansi()

This commit is contained in:
Rob Pearce 2022-07-08 12:49:51 +10:00
parent 1a9f7bbf1d
commit b887074869
1 changed files with 33 additions and 30 deletions

View File

@ -48,38 +48,39 @@ SPINNERFILE="$BASHTOOLS_DIR/spinner.pid"
[[ ! -e $BASHTOOLS_DIR ]] && mkdir "$BASHTOOLS_DIR" [[ ! -e $BASHTOOLS_DIR ]] && mkdir "$BASHTOOLS_DIR"
[[ -e $SPINNERFILE ]] && rm -f "${SPINNERFILE}" [[ -e $SPINNERFILE ]] && rm -f "${SPINNERFILE}"
export BOLD="\033[1m"
export PLAIN="\033[0m"
export ITALIC="\033[3m"
export STRIKE="\033[9m"
export UNDERLINE="\033[4m"
export RED="\033[31m"
export YELLOW="\033[33m"
export GREEN="\033[32m"
export BLUE="\033[34m"
export MAGENTA="\033[35m"
export CYAN="\033[36m"
export ORANGE="${PLAIN}\033[38;2;255;165;0m"
export ORANGEBOLD="${BOLD}\033[38;2;255;220;0m"
export MAGENTARGB="${PLAIN}\033[38;2;208;65;126m"
export MAGENTARGBBOLD="${BOLD}\033[38;2;255;135;196m"
export INFOCOL="$CYAN"
export INFORMCOL="$ORANGE"
export INFORMCOLB="$ORANGEBOLD"
export NOTIFYCOL="$MAGENTARGB"
export NOTIFYCOLB="$MAGENTARGBBOLD"
export GREY="\033[38;2;110;110;110m"
export LINK="$BLUE$UNDERLINE"
export UNDERLINE_PRINTED=$(echo -en "$UNDERLINE")
export UNDERLINE_LENGTH=${#UNDERLINE_PRINTED}
export REGEXP_IP='^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$' export REGEXP_IP='^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$'
function ansi(){
export BOLD="\033[1m"
export PLAIN="\033[0m"
export ITALIC="\033[3m"
export STRIKE="\033[9m"
export UNDERLINE="\033[4m"
export RED="\033[31m"
export YELLOW="\033[33m"
export GREEN="\033[32m"
export BLUE="\033[34m"
export MAGENTA="\033[35m"
export CYAN="\033[36m"
export ORANGE="${PLAIN}\033[38;2;255;165;0m"
export ORANGEBOLD="${BOLD}\033[38;2;255;220;0m"
export MAGENTARGB="${PLAIN}\033[38;2;208;65;126m"
export MAGENTARGBBOLD="${BOLD}\033[38;2;255;135;196m"
export INFOCOL="$CYAN"
export INFORMCOL="$ORANGE"
export INFORMCOLB="$ORANGEBOLD"
export NOTIFYCOL="$MAGENTARGB"
export NOTIFYCOLB="$MAGENTARGBBOLD"
export GREY="\033[38;2;110;110;110m"
export LINK="$BLUE$UNDERLINE"
export UNDERLINE_PRINTED=$(echo -en "$UNDERLINE")
export UNDERLINE_LENGTH=${#UNDERLINE_PRINTED}
}
function noansi() { function noansi() {
local allcols c local allcols c
allcols=$(set | egrep "\\033.*m\'" | sed 's/=.*//') allcols=$(set | egrep "\\033.*m\'" | sed 's/=.*//')
@ -628,5 +629,7 @@ function profile() {
} }
#declare -fx $(bash -c "source $0 &> /dev/null; compgen -A function") #declare -fx $(bash -c "source $0 &> /dev/null; compgen -A function")
ansi
declare -fx $(compgen -A function | grep -v ^_) declare -fx $(compgen -A function | grep -v ^_)