Install Watch Command on OS X
If there was one command I would really complain about not being on Mac OS X, it would be “watch”. Watch is one of those great pieces of software that is tiny and completely out of the way, but when needed it will be a life saver.
It’s simple to explain watch; Watch will run a command repeatedly and then display the output in an “ncurses” friendly manner. Another way to explain this might be to say, you can turn any command line program output into a “real time” display. A good example is using watch to monitor disk usage.
Now of course it’s hard to demonstrate the command running in a repetitive manner using a still image, but this might be something you would want to run when monitoring the amount of space left on your hard drive while transfering a large file(s). If you examine the screen shot closely, in the upper left hand corner you will notice that the command is being run every 5.0s, or 5 seconds. The comand being run, is “df -kh”. The output tells us the disk size, used space, available space and percentage used (capacity) in a human readable format (thats what the “h” stands for in df -kh). As we delete a large portion of files, or copy new files to our computer we will see these values change. If you wanted to see smaller increments you would remove the “h” and just run “df -k”.
The basic usage for watch is: watch -n number_of_seconds “command”
Download the “watch” command from Terminal.app
We are using “curl” a command line “broswer”
curl -O http://ktwit.net/code/watch-0.2-macosx/watch
Make “watch” executable
By doing this we tell Mac OS that this is a program that can run
chmod +x watch
Test the program
Let’s make sure everything is in working order.
Optional: By following this next step we are placing watch into a system location that will allow you to run it from any location in the Terminal (You will be prompted for your password)
sudo mv watch /usr/local/bin/
Congrats, you have added the watch command to your Mac OS X System.