Skip to content

Instantly share code, notes, and snippets.

@ArtiomL
Created January 7, 2014 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArtiomL/8292332 to your computer and use it in GitHub Desktop.
Save ArtiomL/8292332 to your computer and use it in GitHub Desktop.
rp - Command Repeater
#!/bin/bash
# rp - Command Repeater
# (CC0) No Rights Reserved
# Artiom Lichtenstein
# v1.1, 05/01/2014
shopt -s expand_aliases
source ~/.bash_aliases
if [ -z "$1" ]
then
echo; echo "Usage: ./rp {COMMAND} [INTERVAL]"; echo
exit
fi
flt_INTERVAL=0.5
int_COUNT=1
flt_TIME=0
if [ $# -eq 2 ]
then
flt_INTERVAL=$2
fi
while true
do
echo "$(tput setaf 2)$(tput bold)Count: $int_COUNT$(tput sgr0) , $(tput setaf 6)$(tput bold)Time: $flt_TIME sec.$(tput sgr0)"
eval $1
sleep $flt_INTERVAL
flt_TIME=`echo $int_COUNT \* $flt_INTERVAL | bc`
let int_COUNT+=1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment