You're asking two entirely different things here. First you ask what to do to get beeps after one minute, then you ask to get beeps after the command finishes. These are two things that are approached entirely different.
# bof [command] [args...] - Beep on Finish
bof() {
"$@"; local r=$?
printf '\a'
return $r
}
This function runs a command and then beeps one time once the command's done, while making sure that the exit code of the command is the exit code of the function.
# bot [command] [args...] - Beep on Timeout
bot() {
{ sleep 60; printf '\a'; } &
"$@"; local r=$?
kill $!
return $r
}
This function beeps once after a certain time unless the command completed before that time (here, 60
seconds, one minute).
# bem [command] [args...] - Beep every Minute
bem() {
{ while sleep 60; do printf '\a'; done; } &
"$@"; local r=$?
kill $!
return $r
}
This is a simple adaption of the earlier function which beeps every minute for as long as your command is still alive.
# bofem [command] [args...] - Beep on Finish every Minute
bofem() {
"$@"; local r=$?
until read -t 60 -n 1; do printf '\a'; done
return $r
}
And finally, a function that beeps every minute but only after the command has finished. Keeps beeping until you hit a key to stop it. Then, the function returns with the exit code of your command.
I think that'll cover about all the bases you could have intended with your question.
Use (and combine) them like so:
bof rsync foo bar: # Beep when rsync finishes.
bot ssh foo 'ls bar/' # Beep if the 'ssh' process takes too long to run.
bot bof sudo rm -rf / # Beep if removing all your files and directories takes too long and as soon as it finishes.
Obligatory: Yeah, don't run that last command.