• I love such collections. But calling this one a one-liner is a bit of stretch:

    stty -icanon || stty -f /dev/stdin -icanon && perl -e 'use strict; use Time::HiRes qw(usleep gettimeofday); use IO::Select; my $sel=IO::Select->new(); $sel->add(*STDIN); my ($ts,$on,$t0,$td)=(0)x4; print "\n"; while (1){ my $k=0; if($sel->can_read(.02)) {sysread(STDIN,$k,1)} my $t=int(gettimeofday*100)/100; if($k eq "\n") {$on=0;$ts=0} $td=($ts+$t-$t0); if($on){printf "\033[A\r%.2f\033[J\n",$td} if($k){$on=1-$on; if($on){$t0=$t}else{$ts=($ts+$t-$t0)}}}'

      • Yeah, just because there is no newline character, does not make it a one liner. It does not even fit into one line and needs to be soft-broken into next line multiple times. And it includes a whole perl script. :D If anyone want to execute these complex lines, I would recommend to save as a script and let it autoformat to something readable.