Practical Width Examples
Real-World Width Scenarios
1. System Banner Creation
Creating system welcome banners with controlled width:
figlet -f standard -w 60 "Welcome to LabEx" > /etc/motd
figlet -f slant -w 40 "Ubuntu 22.04" >> /etc/motd
Dynamic width for script headers:
#!/bin/bash
terminal_width=$(tput cols)
figlet -c -w $((terminal_width-10)) "System Diagnostic Report"
Width Adaptation Strategies
graph TD
A[Terminal Size] --> B{Width Calculation}
B -->|Fixed Percentage| C[Proportional Width]
B -->|Dynamic Adjustment| D[Responsive Display]
Consistent log header formatting:
function log_header() {
figlet -f small -w 50 -c "$1"
}
log_header "System Update"
log_header "Security Scan"
Comparative Width Demonstrations
Scenario |
Width |
Font |
Purpose |
Narrow Display |
30 |
small |
Compact notifications |
Standard Display |
50 |
standard |
General messages |
Wide Display |
80 |
slant |
Detailed headers |
4. Interactive Width Selection
Interactive script for width customization:
#!/bin/bash
read -p "Enter desired width (30-100): " width
read -p "Enter text: " text
figlet -w "$width" "$text"
Advanced Width Techniques
Conditional Width Rendering
#!/bin/bash
terminal_width=$(tput cols)
if [[ $terminal_width -gt 100 ]]; then
figlet -f banner -w 80 "Full Width Display"
elif [[ $terminal_width -gt 50 ]]; then
figlet -f standard -w 50 "Medium Display"
else
figlet -f small -w 30 "Compact View"
fi
Best Practices
- Always consider terminal size
- Use dynamic width calculations
- Experiment with different fonts
- Maintain readability
By mastering these width techniques, you can create flexible and responsive ASCII text displays in your Linux environment.