Combine styles for custom output?

QuestionsQuestions8 SkillsProDec, 18 2025
0138

Combining styles is where the real magic happens! By chaining tput commands together, you can create professional, multi-layered UI elements directly in your terminal.

In your LabEx environment, try running these examples to see how they look:

You can combine a background color, a text color, and bold text all at once:

# Set background to Green (setab 2), text to White (setaf 7), and Bold
tput setab 2; tput setaf 7; tput bold; echo " SUCCESS "; tput sgr0

Note: tput sgr0 is the "Reset" command that clears all styles at once.

2. The "Warning" Tag (Yellow Background + Underline)

tput setab 3; tput setaf 0; tput smul; echo " ATTENTION: System Update Required "; tput sgr0

Here, we used setaf 0 (black text) on setab 3 (yellow background) with smul (underline).

3. Professional Scripting (The Variable Method)

When you start building your own Challenges (the next step in your LabEx journey), you'll want to use variables to keep things clean. Copy and paste this into your terminal:

# Define your "Theme"
HEADER=$(tput setab 4; tput setaf 7; tput bold)
INFO=$(tput setaf 6)
SUCCESS=$(tput setaf 2)
RESET=$(tput sgr0)

# Use your theme
echo "${HEADER} --- LabEx System Report --- ${RESET}"
echo "${INFO}Status: ${SUCCESS}Environment is Ready!${RESET}"

4. Clearing and Positioning

You can even clear the screen and place a stylized title at the very top:

tput clear; tput cup 0 0; tput setab 7; tput setaf 0; echo " COMMAND CENTER "; tput sgr0

Next Steps in your Learning Journey

As mentioned in the "Learn By Doing" philosophy section of this lab:

  • Guided Labs show you the basics.
  • Challenges will ask you to apply these tricks, like creating a script that displays system info in color.
  • All these steps help you "light up" the Shell Scripting and Terminal Environment branches of your Skill Tree.

You have mastered the terminal basics and beyond! Click Continue to complete this lab and officially record your new skills in your profile! 🚀

0 Comments

no data
Be the first to share your comment!