A small Dart library for writing scripts that feel like shell scripts, plus the scripts I actually use.
Each file in apps/ is one command. make compiles it to a .dill and writes a tiny shell wrapper around it.
lib/dartsh.dart covers the boring parts of a script: running a process and reading what it printed, parsing arguments, reading the environment, writing output, and bailing out with an error. Import it as sh and the code reads close to the shell version.
import 'package:dartsh/dartsh.dart' as sh;
Future<void> main() async {
final taps = await sh.run('brew', ['tap']);
if (!taps.ok) sh.fail(taps.stderr);
sh.emit(taps.lines);
}dart pub get
make stage # compile apps into build/
make install # copy wrappers to ~/bin and dills to ~/bin/scripts
make uninstallSet PREFIX to install somewhere else. While hacking, dart run apps/sleepctl.dart skips the build.
To add a command, drop a file in apps/ and run make again. That's it.