I created a flirt.sh script which just outputs a random sentence with a random color, and now I want it to be ran every time I enter a command
I used trap "~/flirt.sh" DEBUG in .bashrc for that purpose but there's a small problem:
for i in 1; do
echo $i
done
runs flirt.sh two times, and if I use for i in {1..2} the output will be 2 times from script and 1, after that another 2 times from script and 2 e.g., so for each command in loop it runs script 2 times. I'm searching for a method to run command (script) one time after I press enter and before command I typed starts executing, so something like this:
# Nothing typed so script won't be executed
$
# Script and command will be executed
$ ls
Hello from flirt.sh!
Documents Downloads
...
# Script will be executed only once
$ for i in {1..2}; do echo $i; done
Hello from flirt.sh!
1
2
Any tips, please?
\e[?25l)