I started using this answer to print the elapsed command time in my prompt. But whenever I enter fix mode, the trap command is also echoed. Here's an example:
[last: 0s][~]$ sleep 2 && echo hello world
hello world
[last: 2s][~]$ fc
sleep 2 && echo hello world
timer_start
timer_start
hello world
I found this much more complicated prompt that also uses the DEBUG trap, but doesn't suffer from this problem- it just prints the commands and the results:
...$ sleep 2 && echo hello world
hello world
...$ fc
sleep 2 && echo hello world
hello world
But I can't figure out how it accomplishes this. How can I use the first example without having timer_start
echoed for each executed command?