Add htitle

This commit is contained in:
tosu 2024-06-21 03:17:05 +02:00
parent 4fb8226e98
commit bbd8b56aa8
1 changed files with 21 additions and 0 deletions

21
.local/bin/htitle Executable file
View File

@ -0,0 +1,21 @@
#! /bin/sh -
set -e
[ -z "$1" ] && { xargs -n 1 -d '\n' "$0"; exit 0; }
title=$*
title_len=${#title}
[ $title_len -gt 78 ] && { printf '%s\n' "$title"; exit 0; }
missing=$((80 - title_len - 2))
i=0
while [ $i -lt $((missing / 2)) ]; do
printf '#'
i=$((i+1))
done
printf ' %s ' "$title"
while [ $i -lt $missing ]; do
printf '#'
i=$((i+1))
done
printf '\n'