Skip to content

Instantly share code, notes, and snippets.

@flagranterror
Created October 8, 2012 14:24
Show Gist options
  • Save flagranterror/3852795 to your computer and use it in GitHub Desktop.
Save flagranterror/3852795 to your computer and use it in GitHub Desktop.
'Watch' command as a bash function.
# I miss 'watch' on OS X
watch () {
clear
if [ -z $2 ]
then
time="5" # Saneish default
watchedcmd=$1
else
time=$(echo $1 | sed -e 's/-n//')
watchedcmd=$2
fi
while true; do echo "Watching ${watchedcmd} - refreshing every ${time} seconds" ; ${watchedcmd} ; sleep ${time} ;clear; done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment