Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/bash
- delim="$1"
- title="$2"
- titleLength=${#2}
- cols=$COLUMNS
- function printStr {
- delim="${1}"
- length="${2}"
- #eval echo -ne {1..$length}|sed 's/[0-9]*[[:space:]]*/+/g' | tr -d '\n'
- #eval echo {1..$length} | xargs -n 1 -I {} printf "+"
- eval echo {1..$(echo $length)} | xargs -n1 -I {} printf "%s" $delim
- }
- function makeHeaderWithTitle {
- delim="$1"
- cols="$2"
- title="$3"
- titleLength=${#3}
- h1=$(($cols-$(($cols-9))))
- h2=$(($cols-$h1-$titleLength-2))
- shift 2
- title="$@"
- printStr "${delim}" $h1
- echo -ne "[${title}]"
- printStr "${delim}" $h2
- }
- ## BEGIN
- if [[ $# -eq 1 ]]; then
- #no title
- printStr $delim $cols
- elif [[ $# -eq 2 ]]; then
- makeHeaderWithTitle $delim $cols "$title"
- fi
- echo
- ## END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement