From ae36c5d62ed804b5d9ea483e343a44b5b82e4f5a Mon Sep 17 00:00:00 2001 From: candifloss Date: Sun, 23 Aug 2026 15:44:09 +0530 Subject: [PATCH] Watcher script SCSS --- fish/extra/build_scss.fish | 4 ++++ fish/extra/watch_scss.fish | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 fish/extra/watch_scss.fish diff --git a/fish/extra/build_scss.fish b/fish/extra/build_scss.fish index 126e01c..59c3d11 100755 --- a/fish/extra/build_scss.fish +++ b/fish/extra/build_scss.fish @@ -1,5 +1,9 @@ #!/usr/bin/env fish +# This script is used to: +# - Format SCSS, CSS, and Markdown files using `dprint` +# - Compile SCSS to CSS using `grass` + set -l script_path (path resolve (status filename)) set -l script_dir (path dirname "$script_path") set -l project_root (path normalize "$script_dir/../..") diff --git a/fish/extra/watch_scss.fish b/fish/extra/watch_scss.fish new file mode 100755 index 0000000..c1edab6 --- /dev/null +++ b/fish/extra/watch_scss.fish @@ -0,0 +1,30 @@ +#!/usr/bin/env fish + +# Watcher script using `fswatch`. +# - Watch the `scss/` directory for changes. +# - Upon event triggers, run the format+compile script. + +set -l script_path (path resolve (status filename)) +set -l script_dir (path dirname "$script_path") +set -l project_root (path normalize "$script_dir/../..") + +set -l scss_dir "$project_root/scss" +set -l builder "$script_dir/build_scss.fish" + +if not command -q fswatch + echo "error: fswatch is not installed" >&2 + exit 1 +end + +echo "Watching $scss_dir..." +echo "Press Ctrl-C to stop." + +fswatch \ + --recursive \ + --latency=0.1 \ + --one-per-batch \ + "$scss_dir" | +while read -l event + echo "Change detected..." + "$builder" +end