mirror of
https://github.com/Lissy93/dotfiles.git
synced 2025-02-16 15:09:12 +01:00
Adds hr.sh
This commit is contained in:
parent
4264d830e6
commit
9ee0b17c20
35
utils/hr.sh
Normal file
35
utils/hr.sh
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/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
|
||||
# Licensed under MIT (C) Alicia Sykes, 2021
|
||||
|
||||
# Determine width of terminal
|
||||
COLS="$(tput cols)"
|
||||
if (( COLS <= 0 )) ; then
|
||||
COLS="${COLUMNS:-80}"
|
||||
fi
|
||||
|
||||
# Colors
|
||||
CYAN_BG="\u001b[46;1m"
|
||||
RESET="\u001b[0m"
|
||||
|
||||
# Prints the HR line
|
||||
hr() {
|
||||
local CHAR="$1"
|
||||
local LINE=''
|
||||
LINE=$(printf "%*s" "$COLS")
|
||||
LINE="${LINE// /${CHAR}}"
|
||||
printf "${CYAN_BG}${LINE:0:${COLS}}${RESET}"
|
||||
}
|
||||
|
||||
# Passes param and calls hr()
|
||||
start() {
|
||||
for WORD in "${@:--}"; do
|
||||
hr "$WORD"
|
||||
done
|
||||
}
|
||||
|
||||
# Catch errors, and call start
|
||||
[ "$0" == "$BASH_SOURCE" ] && start "$@"
|
Loading…
Reference in New Issue
Block a user