Created
May 28, 2020 06:23
-
-
Save fuzzy/9a9b49d6c34a2384fa06cd9eb93c094e to your computer and use it in GitHub Desktop.
drawing text boxes with Sh and printf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
clr="\033[0m" | |
pad=" " | |
spad=" " | |
setbg() { | |
echo "\033[1;${1};${2}m" | |
} | |
setyx() { | |
echo "\033[${1};${2}H" | |
} | |
clear | |
left_row=10 | |
left_col=20 | |
for color in 41 42 43 44 45 46; do | |
printf "$(setyx ${left_row} ${left_col})$(setbg ${color} 37)${pad}${pad}" | |
printf "$(setyx $((${left_row}+1)) ${left_col})$(setbg ${color} 37)${pad}${pad}" | |
printf "$(setyx $((${left_row}+2)) ${left_col})$(setbg ${color} 37)${pad}${pad}" | |
printf "$(setyx $((${left_row}+3)) ${left_col})$(setbg ${color} 37)${spad}TEST${spad}" | |
printf "$(setyx $((${left_row}+4)) ${left_col})$(setbg ${color} 37)${pad}${pad}" | |
printf "$(setyx $((${left_row}+5)) ${left_col})$(setbg ${color} 37)${pad}${pad}" | |
printf "$(setyx $((${left_row}+6)) ${left_col})$(setbg ${color} 37)${pad}${pad}" | |
left_col=$((left_col - 2)) | |
left_row=$((left_row - 1)) | |
sleep 1 | |
done | |
printf "$(setyx 17 1)" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment