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 <CTRL+S> or save. Then I have a background process that monitors when a file changes, triggers compilation, runs tests, runs programs all concurrently.
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.
|
|
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:
|
|
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.
|
|
Of course, these tools don’t have to be restricted to command line. A single save could trigger page-refresh or live-inject new JavaScript/CSS. A single iteration shouldn’t take more than one gesture.
Don’t waste time pressing buttons that you can automate.