watchrun: Watch and Run
There’s one principle that has helped me to speed up my productivity.
Anytime you make a change in software it should take, at most, one gesture to get feedback.
Usually I’ve found the easiest to make this gesture
This tool was based on Russ Cox “Watch”.
For example, let’s say I have a basic program in main.go. Then I would run these in different consoles.
$1> watchrun go build -i . == ./project $2> watchrun go test ./...
One of these consoles will run tests and the other runs the project itself. All at the press of a button.
Of course the tool can be used in any language you wish:
1 2 3
watchrun -care *.java gradlew run watchrun -care "*.cpp;*.h" g++ -o main main.cpp == ./main watchrun -care *.js node main.js
If you are wondering what the \== means then, it is just a separator to run multiple programs that should be run in sequence. I did not find a nice way to overload standard bash/cmd operators, so it had to suffice.
Of course this tool could also be wired together with an other program.
For example recently I was debugging problems on ARM, but I wanted to use my usual computer to compile and modify code. So, I setup a separate program to listen on the ARM device on a network port. My main program started watching local code and when something changed, ran it locally, compiled it for ARM, sent it to ARM. ARM device received it, wrote to disk and ran it … it’s not very safe, but very useful … and that whole thing ran with one press.
1 2 3 4 5
# ARM named "Other" ./remoterun --addr ":8080" # Main computer GOARCH=arm7 watchrun go build -i . == remoterun -addr "Other:8080" -send program
Don’t waste time pressing buttons that you can automate.