Skip to content

Instantly share code, notes, and snippets.

@shawalli
Forked from flagranterror/gist:3852795
Last active September 14, 2018 14:52
Show Gist options
  • Save shawalli/42bfabebc5ee8bf197ce0ac7b2c1543a to your computer and use it in GitHub Desktop.
Save shawalli/42bfabebc5ee8bf197ce0ac7b2c1543a to your computer and use it in GitHub Desktop.
'Watch' command as a bash script.
#!/bin/bash
# This script *should* work on *nix and Windows, but was designed specifically for git-bash on Windows, to fill the watch gap.
clear
if [ "$#" -gt "2" ] && [ "-n" == "${1:0:2}" ]; then
time=$(echo $1 | sed -e 's/-n//')
shift
watchedcmd=$@
else
time="5" # Saneish default
watchedcmd=$@
fi
while true; do
clear
echo "Watching \"${watchedcmd}\" - refreshing every ${time} seconds"
${watchedcmd}
sleep ${time}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment