diff options
-rwxr-xr-x | ce | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#!/bin/sh + +# ce -- center text + +usage() { echo usage: $0 [-cols] text ... 1>&2; exit 1; } + +case "$1" in +-*) cols=${1#-} + [ "$cols" -gt 0 ] || usage + shift ;; +*) cols=`tput cols` + [ "$cols" -le 80 ] || cols=80 + ;; +esac + +[ $# -gt 0 ] || usage +len=`echo "$@" | wc -c` +max=$(((cols - len) / 2)) +i=0 +while [ $((i++)) -lt $max ]; do + printf ' ' +done +echo "$@" |