-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdrawBlock.sh
More file actions
23 lines (21 loc) · 786 Bytes
/
drawBlock.sh
File metadata and controls
23 lines (21 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
#https://unix.stackexchange.com/questions/70615/bash-script-echo-output-in-box
function box_out() {
input_char=$(echo "$@" | wc -c)
line=$(for i in `seq 0 $input_char`; do printf "-"; done)
# tput This should be the best option. what tput does is it will
# read the terminal info and render the correctly escaped ANSI code
# for you.
# Code like \033[31m will break the readline library in some of the
# terminals.
tput bold
line="$(tput setaf 3)${line}"
space=${line//-/ }
echo " ${line}"
printf '|' ; echo -n "$space" ; printf "%s\n" '|';
printf '| ' ;tput setaf 4; echo -n "$@"; tput setaf 3 ; printf "%s\n" ' |';
printf '|' ; echo -n "$space" ; printf "%s\n" '|';
echo " ${line}"
tput sgr 0
}
box_out $@