diff --git a/home/private_bin/executable_boxify b/home/private_bin/executable_boxify new file mode 100644 index 0000000..ff0476e --- /dev/null +++ b/home/private_bin/executable_boxify @@ -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 " +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 +# } +# +#