Browse Source

Merge pull request #7 from Archund/ansicolors

Added ansiConfig.sh to scripts/
pull/17/head
Jeffery Russell 6 years ago
committed by GitHub
parent
commit
76989ff16d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 0 deletions
  1. +47
    -0
      scripts/ansiConfig.sh
  2. +25
    -0
      scripts/colors.sh

+ 47
- 0
scripts/ansiConfig.sh View File

@ -0,0 +1,47 @@
#!/bin/bash
# ANSI color setup
#use printf or echo -e
defineANSI() {
esc="\e"
# esc="\033"
# Foreground colors
FBLACK="${esc}[30m"
FRED="${esc}[31m"
FGREEN="${esc}[32m"
FYLLW="${esc}[33m"
FBLUE="${esc}[34m"
FPRPL="${esc}[35m"
FCYAN="${esc}[36m"
FWHITE="${esc}[37m"
# Background colors
BBLACK="${esc}[40m"
BRED="${esc}[41m"
BGREEN="${esc}[42m"
BYLLW="${esc}[43m"
BBLUE="${esc}[44m"
BPRPL="${esc}[45m"
BCYAN="${esc}[46m"
BWHITE="${esc}[47m"
# Bold, italic, underline, and inverse style toggles
BOLDON="${esc}[1m"
BOLDOFF="${esc}[22m"
ITALON="${esc}[3m"
ITALOFF="${esc}[23m"
UNDERON="${esc}[4m"
UNDEROFF="${esc}[24m"
BLINK="${esc}[5m"
STATIC="${esc}[25m"
INVON="${esc}[7m"
INVOFF="${esc}[27m"
RESET="${esc}[0m"
}
echo $RESET

+ 25
- 0
scripts/colors.sh View File

@ -0,0 +1,25 @@
#!/bin/bash
options
#STATICthis script sources ansiConfig to set up color variables
. ansiConfig.sh
#--------------------------------------
#set up colors
defineANSI
#use 'echo -e' or printf to parse escape sequences properly
echo -e "${FYLLW}Print colored text with ANSi escape codes! ${RESET}"
echo -e "${BWHITE}${FBLUE}You can define both foreground or background colors ${RESET}"
echo -e "${BCYAN}${FBLACK}Some terminals ${BOLDON}support${BOLDOFF} ${INVON}special${INVOFF} ${ITALON}format${ITALOFF} ${BLINK}options${STATIC}.${RESET}\n\n"
color="echo -e"
$color "You can set up a shortcut for ${ITALON}'echo -e'${ITALOFF} or ${ITALON}'echo -en'${ITALOFF}"
$color "${ITALON}\tcolor=\"echo -e\"${ITALOFF}"
$color "${ITALON}\t\$color \"\${BOLDON}BOLDSTRING\${BOLDOFF}\"${ITALOFF}"
echo -e "\n\nDont forget to ${RESET}RESET the colors\n"

Loading…
Cancel
Save