aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/unix/center_text.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/unix/center_text.sh b/bin/unix/center_text.sh
new file mode 100755
index 0000000..6e3b9b2
--- /dev/null
+++ b/bin/unix/center_text.sh
@@ -0,0 +1,16 @@
1#! /bin/bash
2
3echo '\e[5 q'
4
5while read -r -e text; do
6 tput cuu1 civis
7
8 width="$(tput cols)"
9 left=$(( ($width - ${#text}) /2 ))
10 right=$(( $width - $left - ${#text} ))
11
12 echo -en '\r'
13 eval "printf ' %.0s' {1..$left}"
14 echo -n $text
15 eval "printf ' %.0s' {1..$right}"
16done