-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrgb_bar4.sh
More file actions
executable file
·37 lines (27 loc) · 832 Bytes
/
rgb_bar4.sh
File metadata and controls
executable file
·37 lines (27 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# RGB bar colors (change as needed)
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
# Reset text color
RESET='\033[0m'
# Get terminal width
TERMINAL_WIDTH=$(tput cols)
# Function to display RGB bar filling the terminal width
display_rgb_bar() {
local color=$1
local bar_width=$2
local scaled_width=$((TERMINAL_WIDTH * bar_width))
local num_chars=$(awk -v sw="$scaled_width" 'BEGIN { printf "%.0f", sw/2 }')
for ((i = 0; i < num_chars; i++)); do
echo -en "${color}██${RESET}"
done
echo
}
# Display RGB bars
echo "Red:"
display_rgb_bar $RED 0.5 # Adjust the bar width (currently set to 0.5)
echo "Green:"
display_rgb_bar $GREEN 0.5 # Adjust the bar width (currently set to 0.5)
echo "Blue:"
display_rgb_bar $BLUE 0.5 # Adjust the bar width (currently set to 0.5)