diff options
| author | Robert Günzler <r@gnzler.io> | 2026-04-08 13:18:14 +0900 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2026-04-08 13:18:14 +0900 |
| commit | b61b58ce2c1371d6f904f108fa7feed3abfbe5c7 (patch) | |
| tree | 008a5cf54ecbfffb97ddac30e44c8ab224395ab0 /bin/hr | |
| parent | d4620f3ac119263fee90bd819eadaf84fc8d50b7 (diff) | |
*
Automated-commit-by: dots Signed-off-by: Robert Günzler <r@gnzler.io>
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 "$@" |