#!/usr/bin/env bash # Simple script to output a solid line in the terminal # Useful for marking the end of a task in your bash log # Inspired by @LuRsT's script of the same name # Can be called directly, or source'd in *rc file # # Licensed under MIT, (C) Alicia Sykes 2022 # See: https://github.com/Lissy93/dotfiles # # Modified by Ismo Vuorinen 2023 # Determine width of terminal hr_col_count="$( (tput cols - 4))" if [ -z "${hr_col_count+set}" ] || [ "$hr_col_count" -lt 1 ]; then hr_col_count="${COLUMNS:-80}" fi # Colors CLR_RED="\033[1;31m" hr_color="${hr_color:=$CLR_RED}" hr_reset="\033[0m" # Prints the HR line hr_draw_char() { local CHAR="$1" local LINE="" LINE=$(printf "%*s" "$((hr_col_count - 3))" " ") LINE="${LINE// /${CHAR}}" echo -e "${hr_color}${LINE:0:${hr_col_count}}${hr_reset}" } # Passes param and calls hr() hr() { for WORD in "${@:--}"; do hr_draw_char "$WORD" done } hr "$@"