scripts

My personal collection of scripts
git clone git://src.gearsix.net/scripts
Log | Files | Refs | Atom | README | LICENSE

while-true.sh (666B)


      1 #!/bin/sh
      2 # while-true
      3 # description: clear terminal, run $1, sleep ($2 || 1), repeat (Ctrl+C to cancel)
      4 # e.g.$ while-true "git status" 5
      5 
      6 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
      7 	echo "Usage: while-true \"ACTION\" [SLEEP]"
      8 	echo ""
      9 	echo "while-true will loop infinitely and repeat ACTION every [SLEEP] seconds."
     10 	echo "ACTION should be the terminal command to carry out."
     11 	echo "  Note that it needs to be provided inbetween \"\" marks so as not to be read as multiple arguments"
     12 	echo "SLEEP should provide the number of seconds to sleep for (default: 1)"
     13 	exit
     14 fi
     15 
     16 while [ true ]; do
     17 	clear
     18 	pwd
     19 	$1
     20 	if [ $2 ]; then
     21 		sleep $2
     22 	else
     23 		sleep 1
     24 	fi
     25 done