function __clear_repeat_loop --description "Re-run the last command on a timer, clearing the screen each iteration" set -l last $history[1] or return read -l -P "Ripeti quante volte? (invio = infinito) " count read -l -P "Ogni quanti secondi? (default 2) " sec set -l sec (string match -r '^[0-9]+$' -- $sec) or set sec 2 if test -z "$count"; or test "$count" -eq 0 while true clear eval $last sleep $sec end else for i in (seq $count) clear eval $last sleep $sec end end commandline -f repaint end