mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-29 18:46:09 +00:00
chore(scripts): cleanup x-hr
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
# Modified by Ismo Vuorinen <https://github.com/ivuorinen> 2023
|
||||
|
||||
# Determine width of terminal
|
||||
hr_col_count="$(tput cols)"
|
||||
hr_col_count="$( (tput cols - 4) )"
|
||||
if [ -z "${hr_col_count+set}" ] || [ "$hr_col_count" -lt 1 ]; then
|
||||
hr_col_count="${COLUMNS:-80}"
|
||||
fi
|
||||
@@ -23,10 +23,10 @@ hr_reset="\033[0m"
|
||||
# Prints the HR line
|
||||
hr_draw_char() {
|
||||
local CHAR="$1"
|
||||
local LINE=''
|
||||
LINE=$(printf "%*s" "$((hr_col_count - 2))")
|
||||
local LINE=""
|
||||
LINE=$(printf "%*s" "$((hr_col_count - 3))" " ")
|
||||
LINE="${LINE// /${CHAR}}"
|
||||
echo -e "◀${hr_color}${LINE:0:${hr_col_count}}${hr_reset}▶"
|
||||
echo -e "${hr_color}${LINE:0:${hr_col_count}}${hr_reset}"
|
||||
}
|
||||
|
||||
# Passes param and calls hr()
|
||||
@@ -36,18 +36,5 @@ hr() {
|
||||
done
|
||||
}
|
||||
|
||||
# Determine if file is being run directly or sourced
|
||||
(
|
||||
[[ -n $ZSH_EVAL_CONTEXT && $ZSH_EVAL_CONTEXT =~ :file$ ]] \
|
||||
|| [[ -n $KSH_VERSION && $(cd "$(dirname -- "$0")" \
|
||||
&& printf '%s' "${PWD%/}/")$(basename -- "$0") != "${.sh.file}" ]] \
|
||||
|| [[ -n $BASH_VERSION ]] && (return 0 2>/dev/null)
|
||||
) && sourced=1 || sourced=0
|
||||
|
||||
# Either instantiate immediately, or set alias for later
|
||||
if [ "$sourced" -eq 0 ]; then
|
||||
[ "$0" == "${BASH_SOURCE[0]}" ] && hr "$@"
|
||||
else
|
||||
export alias hr='hr'
|
||||
fi
|
||||
hr "$@"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user