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() { print() {
# if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
echo -e "$*${FRESET}" echo -e "$*${FRESET}"
} }
link() {
echo -e "\e]8;;$2\a$1\e]8;;\a"
}
debug() { debug() {
if [ "$2" ]; then if [ "$2" ]; then
print "${FDIM}${FBOLD}${FRESET}${FDIM}$(now)${IDEBUG} ${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 " >&2 print "${FDIM}${FBOLD}${FRESET}${FDIM}$(now)${IDEBUG} ${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 " >&2
@@ -141,20 +146,53 @@ die() {
exit ${2:-255} exit ${2:-255}
} }
var='test var_dump' # var='test var_dump'
var_dump var # var_dump var
debug 'test debug' # debug 'test debug'
verbose 'test verbose' # verbose 'test verbose'
info 'test info' # info 'test info'
note 'test note' # note 'test note'
success 'test success' # success 'test success'
warn 'test warn' # warn 'test warn'
error 'test error' # error 'test error'
fatal 'test fatal' # fatal 'test fatal'
die 'test die' # die 'test die'
# experiments ============================================================================== # 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://unix.stackexchange.com/a/269085
# https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit # https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
# https://linuxcommand.org/lc3_adv_tput.php # https://linuxcommand.org/lc3_adv_tput.php