docs: def monitor_dir(args):
      """ displaying the changed files """
  
      def show_fp(fp):
          args['MDFILE'] = fp
          pretty = run_args(args)
          print pretty
          print "(%s)" % col(fp, L)
          cmd = args.get('change_cmd')
          if cmd:
              run_changed_file_cmd(cmd, fp=fp, pretty=pretty)
  
      ftree = {}
      d = args.get('-M')
      # was a change command given?
      d += '::'
      d, args['change_cmd'] = d.split('::')[:2]
      args.pop('-M')
      # collides:
      args.pop('-m')
      d, exts = (d + ':md,mdown,markdown').split(':')[:2]
      exts = exts.split(',')
      if not os.path.exists(d):
          print col('Does not exist: %s' % d, R)
          sys.exit(2)
  
      dir_black_list = ['.', '..']
      def check_dir(d, ftree):
          check_latest = ftree.get('latest_ts')
          d = os.path.abspath(d)
          if d in dir_black_list:
              return
  
          if len(ftree) > mon_max_files:
              # too deep:
              print col('Max files (%s) reached' % c(mon_max_files, R))
              dir_black_list.append(d)
              return
          try:
              files = os.listdir(d)
          except Exception, ex:
              print '%s when scanning dir %s' % (col(ex, R), d)
              dir_black_list.append(d)
              return
  
          for f in files:
              fp = j(d, f)
              if os.path.isfile(fp):
                  f_ext = f.rsplit('.', 1)[-1]
                  if f_ext == f:
                      f_ext == ''
                  if not f_ext in exts:
                      continue
                  old = ftree.get(fp)
                  # size:
                  now = os.stat(fp)[6]
                  if check_latest:
                      if os.stat(fp)[7] > ftree['latest_ts']:
                          ftree['latest'] = fp
                          ftree['latest_ts'] = os.stat(fp)[8]
                  if now == old:
                      continue
                  # change:
                  ftree[fp] = now
                  if not old:
                      # At first time we don't display ALL the files...:
                      continue
                  # no binary. make sure:
                  if 'text' in os.popen('file "%s"' % fp).read():
                      show_fp(fp)
              elif os.path.isdir(fp):
                  check_dir(j(d, fp), ftree)
  
  
      ftree['latest_ts'] = 1
      while True:
          check_dir(d, ftree)
          if 'latest_ts' in ftree:
              ftree.pop('latest_ts')
              fp = ftree.get('latest')
              if fp:
                  show_fp(fp)
              else:
                  print 'sth went wrong, no file found'
          sleep()