summary refs log tree commit diff
path: root/bin/hr
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2020-01-26 17:16:07 +0100
committerRobert Günzler <r@gnzler.io>2020-01-26 18:00:59 +0100
commitf5d56602df70950de6b7d40966b00c9939c81763 (patch)
treeb50ffeb5496fe3525cc1bab2629389ced95435b7 /bin/hr
Intial commit of v2
See https://drewdevault.com/2019/12/30/dotfiles.html
Diffstat (limited to 'bin/hr')
-rwxr-xr-xbin/hr20
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/hr b/bin/hr
new file mode 100755
index 0000000..9c421fc
--- /dev/null
+++ b/bin/hr
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+str="$1"
+[[ -n $str ]] && str=" $str "
+getcols() {
+    if command -v tput &>/dev/null; then
+        tput cols
+    else
+        stty size | awk '{print $2}'
+    fi
+}
+COLS=$((${COLUMNS:-`getcols`} - ${#str} - 2))
+start=$'\e(0'; end=$'\e(B'; line="qqqqqqqqqqqqqqqq"
+while ((${#line}<$COLS)); do line+=$line; done
+printf "╾" # └
+printf "%s%s%s" "$start" "${line:0:$((COLS/2))}" "$end"
+printf "%s" "$str"
+printf "%s%s%s" "$start" "${line:0:$((COLS/2))}" "$end"
+printf "╼" # ┐
+printf "\n"