1

I'm Creating a Login Screen when I start my CLI Arch Linux and I build a script on the file

/etc/bash.bashrc

Like as it follows below:

#COMMANDS CREATED INSIDE /ETC/BASH.BASHRC FILE
# USING ANSI COLORS
RED="\e[31m"
ORANGE="\e[33m"
BLUE="\e[94m"
GREEN="\e[92m"
STOP="\e[0m"


# LOGIN SCREEN MESSAGE 
screenfetch
printf "${GREEN}"
printf "=================================\n"
printf "${ORANGE}"
figlet -w 200 -f standard "F4NT0 ARCH LINUX"
printf "${BLUE}"
figlet -w 200 -f  small "CLI Operational System"
printf "${GREEN}"
printf "=================================\n"
printf "${STOP}"

In the code above, I build the variables who calls the colors and I let "leak" on the messages created with the figlet program using the printf.

This way I can color the messages until the last variable call(the message below stay with the color i call in the variable above), when I call the next variable,the code change the color from the next message and so on until the STOP variable who stop the leaking of the colors.

The Login Letters

I like how it works in my Arch, but programable way I find it "dirty"...

There is a way to add colors(ANSI,tput or others) in the figlet command to become more adequate to add colors inside Scripts in Unix/Linux?

0

The way I show In this Question is the Best Way to Put Colors on Figlet, the Way a color is putting before the commands is the Only way I find to Make it work, And after I call the next Color,the next line will be Change to The New Color!!

If anyone want to Know, the Way I call the colors is using the ANSI color codes, like Below:

Regular Colors:

  • \e[30m = Black
  • \e[31m = Red
  • \e[32m = Green
  • \e[33m = Yellow
  • \e[34m = Blue
  • \e[35m = Purple
  • \e[36m = Cyan
  • \e[37m = White

Light Colors:

  • \e[90 = Light Black
  • \e[91 = Light Red
  • \e[92 = Light Green
  • \e[93 = Light Yellow
  • \e[94 = Light Blue
  • \e[95 = Light Purple
  • \e[96 = Light Cyan
  • \e[97 = Light White

The way I use isn´t the only way, not even the complete one

For the Complete Informations About ANSI colors, read this Site:

https://misc.flogisoft.com/bash/tip_colors_and_formatting

About The Variables:

  • I put the color name all in Caps because is the best way to avoid Confusion

GREEN="\e[92m"

  • To call the Variable Created, you need to catch the value of the Vaiable, Using the ${} construction

${GREEN}

  • To make the Color out before the command, you need to use printf to leak the Color(I use Printf but I think echo works too).

printf "${GREEN}"

  • The Next Line who Print Something on the Screen Will have the Color of the Variable.

printf "${GREEN}"

figlet -f standard "This Will Be Green"

The Text Should Be Like This:

Test

  • To Stop the Color Leak Inside Where it Shouldn´t, there´s Two Steps:
    • If you want to put a New Color, Just Call the New Color
    • If you want to Stop the Color, Use the Following Variable:

      STOP="\e[0m"

      • Put the Stop in the End where after that you Don´t want to Change the color like that:

      printf "${STOP}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.