-1

!/bin/bash

this script is to show different text foregrounds and backgrounds

the first two variables are the format variables for each line that I will have to put spacing into.

    FORMAT_STRING='%b%30s%30s\n'
    DEFAULT='\033[0m'

These variables are used to shortcut the color codes into the approprate line

    RED_ON_BLACK='\033[31;40m'
    YELLOW_ON_BLACK='\033[33;40m'
    REVERSED='\033[7m'
    UNDERLINED='\033[4m'
    BLINKING_YELLOW_ON_RED='\033[33;41;5m'
    BLUE_ON_BLACK='\033[36;40m'
    WHITE_ON_CYAN='\033[37;46m'

The first two lines are my ruler and how I determine and match spacing

    printf '%0.s1234567890' {0..9};echo
    printf '%10s' {10..100..10};echo 
    printf '%30s%30s\n' 'Color Combination' 'Escape Sequence';printf '%-18s'

I have had to resort to adding additional space on the line before

    printf $FORMAT_STRING $RED_ON_BLACK'Red on Black'$DEFAULT $RED_ON_BLACK;printf '%-15s'
    printf $FORMAT_STRING $YELLOW_ON_BLACK'Yellow on Black'$DEFAULT $YELLOW_ON_BLACK;printf '%-22s'
    printf $FORMAT_STRING $REVERSED'Reversed'$DEFAULT $REVERSED;printf '%-20s'
    printf $FORMAT_STRING $UNDERLINED'Underlined'$DEFAULT $UNDERLINED;printf '%-4s'
    printf $FORMAT_STRING $BLINKING_YELLOW_ON_RED'Blinking ignored on Ubuntu'$DEFAULT $BLINKING_YELLOW_ON_RED;printf '%-17s'
    printf $FORMAT_STRING $BLUE_ON_BLACK'Blue on Black'$DEFAULT $BLUE_ON_BLACK;printf '%-17s'
    [enter image description here][1]printf $FORMAT_STRING $WHITE_ON_CYAN'White on Cyan'$DEFAULT $WHITE_ON_CYAN

STILL NEEDING HELP HOW TO GET FOREGROUND AND BACKGROUND COLOR TO EXTEND #FROM BEGINNING OF EACH LINE THEY OCCUPY

1 Answers1

0

!/bin/bash

this script is to show different text foregrounds and backgrounds

the first two variables are the format variables for each line that I will have to put spacing into.

    FORMAT_STRING='%b%30s%b%30s\n'
    DEFAULT='\033[0m'

These variables are used to shortcut the color codes into the approprate line

    RED_ON_BLACK='\033[31;40m'
    YELLOW_ON_BLACK='\033[33;40m'
    REVERSED='\033[7m'
    UNDERLINED='\033[4m'
    BLINKING_YELLOW_ON_RED='\033[33;41;5m'
    BLUE_ON_BLACK='\033[36;40m'
    WHITE_ON_CYAN='\033[37;46m'

The first two lines are my ruler and how I determine and match spacing

    printf '%0.s1234567890' {0..9};echo
    printf '%10s' {10..100..10};echo 
    printf '%30s%30s\n' 'Color Combination' 'Escape Sequence'

Theses are the color sequences

    printf $FORMAT_STRING $RED_ON_BLACK 'Red on Black' $DEFAULT $RED_ON_BLACK
    printf $FORMAT_STRING $YELLOW_ON_BLACK 'Yellow on Black' $DEFAULT $YELLOW_ON_BLACK
    printf $FORMAT_STRING $REVERSED 'Reversed' $DEFAULT $REVERSED
    printf $FORMAT_STRING $UNDERLINED 'Underlined' $DEFAULT $UNDERLINED
    printf $FORMAT_STRING $BLINKING_YELLOW_ON_RED 'Blinking ignored on Ubuntu' $DEFAULT $BLINKING_YELLOW_ON_RED 
    printf $FORMAT_STRING $BLUE_ON_BLACK 'Blue on Black' $DEFAULT $BLUE_ON_BLACK
    printf $FORMAT_STRING $WHITE_ON_CYAN 'White on Cyan' $DEFAULT $WHITE_ON_CYAN

I was forgetting the space after the $RED_ON_BLACK before 'Red on Black' and after, before $Default