Automatically reload command in terminal after its run?

Joined
Nov 4, 2021
Messages
1
Reaction score
0
Hi,

I am using the following command in Terminal [screencapture -D2 "path to save folder"`date +%Y-%m-%d_%H-%M-%S`".png"] to take several screencaps rapidly one after the other.

Right now, to repeat the command, I use up arrow, then enter.

Wondering if there would be a simple way for the line of command to be automatically reloaded in the next line (after its run) so that pressing enter would be the only action needed to take another screencap?
 
Joined
Jan 25, 2017
Messages
1,264
Reaction score
99
A shell script could do it. Something like this using the 'a' key as a trigger :

#!/bin/bash



while true; do

read -rsn1 input

if [ "$input" = "a" ]; then

screencapture -D2 "path to save folder"`date +%Y-%m-%d_%H-%M-%S`".png"

fi

done
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top