Created
September 9, 2018 10:06
-
-
Save henryefranks/5ff9c575581b4863a6b87e5fefe8eec0 to your computer and use it in GitHub Desktop.
A Bash script for drawing CLI boxes
This file contains 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
box_width=$(tput cols) | |
function create_line() { | |
input_width=$(($(echo "$*" | wc -c) - 1)) | |
if [ $# -lt 1 ]; then | |
input_width=0 | |
fi | |
half_width=$(($(($box_width - $input_width)) / 2)) | |
for i in `seq 1 $half_width`; do | |
echo -n '-' | |
done | |
echo -n $* | |
half_width=$(($box_width - $half_width - $input_width)) | |
for i in `seq 1 $half_width`; do | |
echo -n '-' | |
done | |
echo | |
} | |
function box_output() { | |
echo -n '| ' "$*" | |
input_length=$(echo $* | wc -c) | |
for i in `seq 1 $(($box_width - $input_length - 4))`; do | |
echo -n ' ' | |
done | |
echo ' |' | |
} | |
function create_divider() { | |
echo -n '|' | |
for i in `seq 1 $(($box_width - 2))`; do | |
echo -n '-' | |
done | |
echo -n '|' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment