add boxify for no reason
This commit is contained in:
parent
eab5d644fb
commit
ea1ef0fe42
1 changed files with 66 additions and 0 deletions
66
home/private_bin/executable_boxify
Normal file
66
home/private_bin/executable_boxify
Normal file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
border_color=5
|
||||
text_color=4
|
||||
|
||||
# why not python?
|
||||
|
||||
function boxify() {
|
||||
local s=("$@") b w
|
||||
for l in "${s[@]}"; do
|
||||
((w < ${#l})) && {
|
||||
b="$l"
|
||||
w="${#l}"
|
||||
}
|
||||
done
|
||||
tput setaf $border_color
|
||||
echo "╭─${b//?/─}─╮
|
||||
│ ${b//?/ } │"
|
||||
for l in "${s[@]}"; do
|
||||
printf '│ %s%*s%s │\n' "$(tput setaf $text_color)" "-$w" "$l" "$(tput setaf $border_color)"
|
||||
done
|
||||
echo "│ ${b//?/ } │
|
||||
╰─${b//?/─}─╯"
|
||||
tput sgr 0
|
||||
}
|
||||
|
||||
# parse args
|
||||
if [[ "$#" -eq 0 ]]; then
|
||||
set -- "use boxify <text>"
|
||||
fi
|
||||
|
||||
boxify "$@"
|
||||
# 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
# A ╷ ╶ ┌ ╴ ┐ ─ ┬ ╵ │ └ ├ ┘ ┤ ┴ ┼
|
||||
# B ╭ ╮ ╰ ╯
|
||||
#
|
||||
# 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
# U+250x ─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏
|
||||
# U+251x ┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟
|
||||
# U+252x ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯
|
||||
# U+253x ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿
|
||||
# U+254x ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏
|
||||
# U+255x ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟
|
||||
# U+256x ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯
|
||||
# U+257x ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿
|
||||
|
||||
# function boxify() {
|
||||
# local s=("$@") b w
|
||||
# for l in "${s[@]}"; do
|
||||
# ((w < ${#l})) && {
|
||||
# b="$l"
|
||||
# w="${#l}"
|
||||
# }
|
||||
# done
|
||||
# tput setaf 3
|
||||
# echo " -${b//?/-}-
|
||||
# | ${b//?/ } |"
|
||||
# for l in "${s[@]}"; do
|
||||
# printf '| %s%*s%s |\n' "$(tput setaf 4)" "-$w" "$l" "$(tput setaf 3)"
|
||||
# done
|
||||
# echo "| ${b//?/ } |
|
||||
# -${b//?/-}-"
|
||||
# tput sgr 0
|
||||
# }
|
||||
#
|
||||
#
|
Loading…
Reference in a new issue