This commit is contained in:
2025-02-08 13:23:48 +08:00
parent 3696cc06af
commit 66126167c8

View File

@@ -76,9 +76,14 @@ ask() {
}
print() {
# if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
echo -e "$*${FRESET}"
}
link() {
echo -e "\e]8;;$2\a$1\e]8;;\a"
}
debug() {
if [ "$2" ]; then
print "${FDIM}${FBOLD}${FRESET}${FDIM}$(now)${IDEBUG} ${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 " >&2
@@ -141,20 +146,53 @@ die() {
exit ${2:-255}
}
var='test var_dump'
var_dump var
debug 'test debug'
verbose 'test verbose'
info 'test info'
note 'test note'
success 'test success'
warn 'test warn'
error 'test error'
fatal 'test fatal'
die 'test die'
# var='test var_dump'
# var_dump var
# debug 'test debug'
# verbose 'test verbose'
# info 'test info'
# note 'test note'
# success 'test success'
# warn 'test warn'
# error 'test error'
# fatal 'test fatal'
# die 'test die'
# experiments ==============================================================================
# spinner() {
# local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
# local spin_i=0
# local interval=0.1
# printf "\e[?25l"
# local color="${FGREEN}"
# while true; do
# printf "\r ${color}%s${CL}" "${frames[spin_i]}"
# spin_i=$(( (spin_i + 1) % ${#frames[@]} ))
# sleep "$interval"
# done
# }
# echo "lorem ipsum dolor sit amet"
# spinner &
# SPINNER_PID=$!
# ===========
# https://unix.stackexchange.com/a/269085
# https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
# https://linuxcommand.org/lc3_adv_tput.php