diff options
Diffstat (limited to 'bin/hr')
| -rwxr-xr-x | bin/hr | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/hr b/bin/hr new file mode 100755 index 0000000..8231ae1 --- /dev/null +++ b/bin/hr @@ -0,0 +1,22 @@ +#!/bin/bash +set -eu +function print_hr() { + local str cols + local start line end + + str="${1:-}" + [[ -n $str ]] && str=" $str " + cols=$((${COLUMNS:-$(tput cols)} - ${#str} - 3)) + # start=$'\e(0'; end=$'\e(B'; line="qqq" + start=''; end=''; line="─" + while ((${#line}<$cols)); do line+=$line; done + + printf "╾" + printf "%s%s%s" "$start" "${line:0:$((cols/2))}" "$end" + printf "%s%s%s" "$start" "${line:0:$((cols/2))}" "$end" + printf "%s" "$str" + printf "%s%s%s" "$start" "${line:0:1}" "$end" + printf "╼" + printf "\n" +} +print_hr "$@" |