• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Jeff Mikels

…biblical Christianity without conservative idolatry…

  • Home
  • All My Sermons
  • My Blog
    • Longer Articles
    • Christian Leadership
    • Spiritual Health
    • Tough Questions
    • Geekery
    • All Posts
  • About Me
    • My Books
    • My Church
    • FAQ
  • Show Search
Hide Search
Home/Geekery/Simple ‘watch’ command for Mac OS X

Simple ‘watch’ command for Mac OS X

I’ve been disappointed that the Mac OS doesn’t provide a watch command. It’s a very useful command, so its absence from the operating system has always baffled me. Well, after using simple bash before, I finally implemented a better replacement in python.

Here is version 0.1

#!/usr/bin/env python
import os
import time
import datetime
import sys


INTERVAL_SECONDS = 2

if len(sys.argv) == 1:
    print ('USAGE: %s command' % (sys.argv[0]))


if __name__ == '__main__':

    args = sys.argv[1:]
    cmd = []
    for item in args:
        item = item.replace('"', '\\"')
        if ' ' in item:
            item = '"%s"' % item

        cmd.append(item)

    cmd_string = ' '.join(cmd)

    # watch loop
    try:
        while 1:
            os.system('clear')

            head = 'watch - %s' % datetime.datetime.now().isoformat()
            subhead = '$ %s\nrepeating every %s seconds\n' % (cmd_string, INTERVAL_SECONDS) + '=' * 60
            print(head)
            print(subhead)
            os.system(cmd_string)
            time.sleep(INTERVAL_SECONDS)
    except KeyboardInterrupt:
        print ("")
        exit()

Written by:
Jeff Mikels
Published on:
November 26, 2013
Thoughts:
No comments yet

Categories: Geekery

Previous Post: « There’s an app for that…
Next Post: Commitment Sunday for Introverts »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Articles

Dear Christian Conservative: Vote Your Conscience

Today is Super Tuesday meaning that a large number of states are having their primaries for the Presidential election. Currently, for …

Continue Reading about Dear Christian Conservative: Vote Your Conscience

Let’s Talk about Salvation: Part 2

Salvation and Forgiveness in the Gospel of John In my previous post, I considered a large number of passages in the synoptic gospels (Matthew, …

Continue Reading about Let’s Talk about Salvation: Part 2

Let’s Talk About Salvation and Forgiveness: Part 1

I've been thinking a lot about this idea recently: What would it look like if we were as eager to forgive as Jesus was? This is a tough …

Continue Reading about Let’s Talk About Salvation and Forgiveness: Part 1

Evangelical Idolatry

I've been going through a dilemma. The question on my mind is this: How do I talk about my book with people who don't know me all that …

Continue Reading about Evangelical Idolatry

Explore more

Footer

About Me

Jeff Mikels • 765-404-0807

Copyright © 2025 · Log in

  • Home
  • Blog
  • About Me
  • FAQ
  • Contact