• Stars
    star
    128
  • Rank 281,044 (Top 6 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created about 12 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Repeat commands!
  ##############################
 #  ____    ___   ____  ______  #
 # |    \  /  _] /    T|      T #
 # |  o  )/  [_ Y  o  ||      | #
 # |   _/Y    _]|     |l_j  l_j #
 # |  |  |   [_ |  _  |  |  |   #
 # |  |  |     T|  |  |  |  |   #
 # l__j  l_____jl__j__j  l__j   #
 #                              #
  #####                    #####
       # Repeat commands! #
        ##################

peat repeats commands.

It's kind of like Kicker except:

  • It doesn't use inotify or OS X FSEvents, so it'll run anywhere.
  • It doesn't require external libraries, so it'll run anywhere with Python.
  • It won't eat your CPU (unless you try to watch too much).
  • It takes paths to watch on standard input so you can use something like find(1) or friendly-find to specify what to watch.

Table of Contents

[TOC]

Installation

Get the peat script on your machine and into your $PATH somehow. Copy and paste it, curl it, or clone the repository. Make sure it's executable. That's it.

Usage

Generate a list of files you want to watch for changes, separated by whitespace. echo(1), find(1) or friendly-find are good for this:

$ ffind '.*.py$'
./foo.py
./bar.py

$ echo *.py
foo.py bar.py

Now pipe that to peat, and specify the command you want to run whenever one of those files changes:

$ ffind '.*.py$' | peat 'echo "A file changed!"'

Use Ctrl-C to stop.

The command to run needs to be specified as a single argument to peat. You can do this with a shell string as seen above. Using a single-quoted string like this will preserve wildcards and such:

$ ffind '.*.py$' | peat 'rm *.pyc'

This will delete all .pyc files in the current directory when a Python file is modified. Google around for "shell quoting" if you don't understand what's happening here.

Dynamic File Listing

If you want to build the file list fresh each time (so that peat will pick up newly created files without having to restart it) you can use the --dynamic option.

Instead of piping in the list of files to watch, you'll specify a command that peat will run to generate the list before every check (as well as the actual command to run, of course). For example:

$ ffind ".markdown$"
./foo.markdown
./bar/baz.markdown

$ peat --dynamic 'ffind ".markdown$"' 'echo "A file changed!"'

Tips & Tricks

Watch all the files Mercurial is tracking (instead of hand-crafting a find command to output that list) and run make on changes:

$ hg files | peat make

Full Usage

Here's the full usage:

Usage: peat [options] COMMAND

COMMAND should be given as a single argument using a shell string.

A list of paths to watch should be piped in on standard input.

For example:

    find . | peat './test.sh'
    find . -name '*.py' | peat 'rm *.pyc'
    find . -name '*.py' -print0 | peat -0 'rm *.pyc'

If --dynamic is used, the given command will be run each time to generate the
list of files to check:

    peat --dynamic 'find .' './test.sh'
    peat --dynamic 'find . -name '\''*.py'\''' 'rm *.pyc'


Options:
  -h, --help            show this help message and exit
  -i N, --interval=N    interval between checks in milliseconds
  -I, --smart-interval  determine the interval based on number of files
                        watched (default)
  -d COMMAND, --dynamic=COMMAND
                        run COMMAND before each run to generate the list of
                        files to check
  -D, --no-dynamic      take a list of files to watch on standard in (default)
  -c, --clear           clear screen before runs (default)
  -C, --no-clear        don't clear screen before runs
  -v, --verbose         show extra logging output (default)
  -q, --quiet           don't show extra logging output
  -w, --whitespace      assume paths are separated by whitespace (default)
  -n, --newlines        assume paths are separated by newlines
  -s, --spaces          assume paths are separated by spaces
  -0, --zero            assume paths are separated by null bytes

License

Copyright 2016 Steve Losh and contributors.

Licensed under version 3 of the GPL.

Remember that you can use GPL'ed software through their command line interfaces without any license-related restrictions. peat's command line interface is the only stable one, so it's the only one you should ever be using anyway. The license doesn't affect you unless you're:

  • Trying to copy the code and release a non-GPL'ed version of peat.
  • Trying to use it as a Python module from other Python code (for your own sanity I urge you to not do this) and release the result under a non-GPL license.

More Repositories

1

gundo.vim

A git mirror of gundo.vim
Vim Script
1,460
star
2

learnvimscriptthehardway

Shell
1,332
star
3

badwolf

A Vim color scheme.
Vim Script
1,229
star
4

t

A command-line todo list manager for people that want to finish tasks, not organize them. (git mirror)
Python
723
star
5

vitality.vim

Make Vim play nicely with iTerm 2 and tmux.
Vim Script
321
star
6

dotfiles

A git mirror of my dotfiles (.vimrc, .zshrc, .hgrc, etc). Note: this won't work on its own because the real repo uses Mercurial's subrepos. Look at .hgsub and .hgsubstate for what you'll need to get.
Vim Script
300
star
7

splice.vim

A Vim plugin for managing three-way merges.
Python
240
star
8

friendly-find

A friendlier find(1).
Python
210
star
9

caves

The code for my Caves of Clojure series of blog posts.
Clojure
157
star
10

clam.vim

A lightweight Vim plugin for working with shell commands.
Vim Script
148
star
11

d

Markdown files to documentation. Nothing else.
CSS
134
star
12

z-fish

A fork of http://github.com/rupa/z to port it to the Fish shell.
Shell
134
star
13

stevelosh

A git mirror of my personal site.
JavaScript
125
star
14

cl-chip8

chip-8 emulator in common lisp
Common Lisp
73
star
15

threesome.vim

A git mirror of threesome.vim.
Python
69
star
16

temperance

A logic programming library for Common Lisp.
Common Lisp
53
star
17

tslime2.vim

Send text from Vim to a tmux pane.
Vim Script
50
star
18

clojurecraft

A framework for writing Minecraft bots in Clojure. STILL ALPHA!
Clojure
40
star
19

stoat

A sleek, lightweight, pluggable CMS app for Django.
Python
39
star
20

cl-losh

Common Lisp
33
star
21

red-tape

A Clojure library for working with forms.
Clojure
30
star
22

bookmarkdown

CSS
29
star
23

flask-lesscss

A git mirror of flask-lesscss.
Python
26
star
24

adopt

A Damn OPTion parsing library.
Common Lisp
24
star
25

strftimedammit.vim

A single Vim documentation file that lists strftime-like formatting characters for a variety of languages.
23
star
26

flask-csrf

A git mirror of flask-csrf.
Python
22
star
27

beast

Basic Entity/Aspect/System Toolkit
Common Lisp
21
star
28

cl-digraph

A simple directed graph implementation for Common Lisp.
Common Lisp
21
star
29

cl-nrepl

NREPL server for Common Lisp
Common Lisp
19
star
30

flax

Weaving art from seeds.
Common Lisp
19
star
31

dram

Clojure templating that won't make you drink.
Clojure
17
star
32

cl-blt

Common Lisp bindings for bearlibterminal, with a Lispy interface on top.
Common Lisp
17
star
33

tis100.vim

Git mirror of tis100.vim
Vim Script
15
star
34

rldt

Common Lisp
15
star
35

roul

A tiny Clojure library for working with random numbers.
Clojure
15
star
36

newseasons

A simple Clojure webapp for notifying users when new seasons of their favorite TV shows hit iTunes.
Clojure
15
star
37

coding-math

Common Lisp
12
star
38

pgworld

Procedural world generation in Unity (for GEDE at ReykjavΓ­k University 2016)
C#
10
star
39

bobbin

Bobbin wraps strings.
Common Lisp
9
star
40

typkov

Clojure
9
star
41

django-hoptoad

I don't have time to work on django-hoptoad much any more, but there's a more active fork:
Python
9
star
42

keymando-vim

A Keymando plugin to add a Vim-like editing mode everywhere.
Ruby
7
star
43

euler

Project Euler
Common Lisp
7
star
44

sand

Common Lisp
7
star
45

advent

Git mirror of https://bitbucket.org/sjl/advent
Common Lisp
6
star
46

scully

A General Game Player for imperfect-information games.
Common Lisp
6
star
47

chancery

A text and data generation library for Common Lisp, inspired by Tracery.
Common Lisp
6
star
48

zen

A throwaway roguelike non-game in Clojure.
Clojure
5
star
49

alienscript

Look at the wiki.
JavaScript
5
star
50

mazes

Common Lisp
5
star
51

introduction-to-mathematical-thinking

My notes/work for the Coursera Intro to Mathematical Thinking course.
5
star
52

silt2

Lisp Game Jam August 2016
Common Lisp
4
star
53

silt

Ludum Dare 34
Clojure
4
star
54

cl-netpbm

Common Lisp support for reading/writing PPM, PGM, and PBM files.
Common Lisp
4
star
55

st

Mirror of st with my config and patches applied
C
4
star
56

flask-urls

A git mirror of flask-urls.
Python
4
star
57

cl-ggp

Git mirror of https://bitbucket.org/sjl/cl-ggp/
Common Lisp
4
star
58

brows

urlview in common lisp
Common Lisp
3
star
59

antipodes

https://itch.io/jam/igi-1
Common Lisp
3
star
60

dtach

A tiny program that emulates the detach feature of screen
Shell
3
star
61

boots

A simple text UI framework, inspired by _why's Shoes.
Common Lisp
3
star
62

magitek

Whimsical robots infused with just a hint of magic.
Common Lisp
3
star
63

cl-pcg

Permuted congruential generators in Common Lisp
Common Lisp
2
star
64

eve

My talk at BACON 2012.
Clojure
2
star
65

bones

Git mirror of https://bitbucket.org/sjl/bones/
2
star
66

gdl.vim

Git mirror of https://bitbucket.org/sjl/gdl.vim
Vim Script
2
star
67

merge-conflict-test

A simple repo that provides two branches with a merge conflict.
2
star
68

vex

Yet another vector math library for Common Lisp.
Common Lisp
2
star
69

.plan

Git mirror of https://hg.stevelosh.com/.plan/
2
star
70

ruin

Clojure
2
star
71

els

The Exciting Lisp Solver!
Common Lisp
1
star
72

beef

shavin beefalos in common lisp
Common Lisp
1
star
73

slock

fork of https://tools.suckless.org/slock/ with my patches
C
1
star
74

batty

A 2D Batformer for the October 2017 Lisp Game Jam.
Common Lisp
1
star
75

sm-slurm-example

Demo of snakemake/slurm problem
Python
1
star
76

cacl

Common Lisp
1
star
77

hype

Common Lisp
1
star
78

rosalind

Rosalind problems.
Common Lisp
1
star
79

fern

Common Lisp
1
star
80

conserve

Yet Another CSV Library for Common Lisp.
Common Lisp
1
star
81

cl-gameboy

Common Lisp
1
star
82

dbvolve

Database evolutions for Common Lisp.
Common Lisp
1
star
83

constrained-game

C#
1
star