nix-files/pkgs/additional/sane-scripts/src/sane-dev-cargo-loop
Colin c50a4d1d71 static-nix-shell: fix mkBash scripts to actually be invokable from the CLI
they need the `bash` package! how did this work before?
2024-06-15 07:42:04 +00:00

32 lines
880 B
Plaintext
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p inotify-tools -p ncurses
# watches PWD for any changes underneath it and re-runs `cargo build --a>
# optionally, provide your own build command as the first argument
external_cmd="cargo build --all"
if [ -n "$1" ]
then
external_cmd=$1
fi
# run this once before starting the inotify
$external_cmd
# other interesting commands to monitor:
# - -e move
# - -e create
# - -e delete
# - -e close_write
# but most (except close_write) seem to cause multiple events per vim :w
# TODO: consider using watchman: https://facebook.github.io/watchman/
# - watchman waits for the root to settle before invoking my command
# so, fewer runs
inotifywait --monitor --recursive \
--timefmt '%d/%m/%y %H:%M' --format '%T %w %f' \
-e modify ./ |
while read -r date time dir file
do
tput reset
$external_cmd
done