Skip to content

Instantly share code, notes, and snippets.

@chmouel
Created April 23, 2025 13:03
Show Gist options
  • Save chmouel/69da429e61aa59a1b25c3a9481d36d4c to your computer and use it in GitHub Desktop.
Save chmouel/69da429e61aa59a1b25c3a9481d36d4c to your computer and use it in GitHub Desktop.
doloop function again and again
doloop () {
local timeout label
label="Press any key to continue"
[[ $1 == -t* ]] && {
timeout="-t${1#-t}"
label="Waiting for ${1} seconds, or press any key to continue"
shift
}
[[ ${1} == "-n" ]] && {
shift
nowait=true
}
while true
do
clear
$@
[[ -n ${nowait} ]] && continue
echo ${label}
read ${timeout} -k1 -s
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment