From 66126167c81dfaa64630267c0a333c102d2a1044 Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Sat, 8 Feb 2025 13:23:48 +0800 Subject: [PATCH] io misc --- helpers/io.sh | 60 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/helpers/io.sh b/helpers/io.sh index 724dadb..d599bb9 100644 --- a/helpers/io.sh +++ b/helpers/io.sh @@ -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