Skip to content

Instantly share code, notes, and snippets.

@mcsf
Last active October 3, 2025 18:34
Show Gist options
  • Select an option

  • Save mcsf/56911ae03c6d87ec61429cefc7707cb7 to your computer and use it in GitHub Desktop.

Select an option

Save mcsf/56911ae03c6d87ec61429cefc7707cb7 to your computer and use it in GitHub Desktop.
Calypso AnyBar handler
#!/bin/bash
PORT="${PORT:-1738}"
DONE_COLOR="${DONE_COLOR:-"black"}"
PROGRESS_COLOR="${PROGRESS_COLOR:-"white"}"
INITIAL_COLOR="${INITIAL_COLOR:-"white"}"
BUILD_ERROR_COLOR="${BUILD_ERROR_COLOR:-"red"}"
TEST_ERROR_COLOR="${TEST_ERROR_COLOR:-"purple"}"
HAS_ERROR=0
main() {
reset_icon
tee >(update_status)
}
update_status() {
while read line
do
if [[ "$line" =~ "webpack: Compiled successfully." ]]; then
if [ $HAS_ERROR -eq 0 ]; then
set_icon "$DONE_COLOR"
else
set_icon "$BUILD_ERROR_COLOR"
fi
elif [[ "$line" =~ "webpack: Compiling..." ]]; then
HAS_ERROR=0
set_icon "$PROGRESS_COLOR"
elif [[ "$line" =~ "ERROR" ]]; then
HAS_ERROR=1
# for `npm run test-client:watch`
elif [[ "$line" =~ "restarting due to changes" ]]; then
reset_icon
# for both test-client and test-client:watch
elif [[ "$line" =~ "app crashed" ]] || [[ "$line" =~ ^[0-9]+\ failing$ ]]; then
set_icon "$TEST_ERROR_COLOR"
fi
done
}
set_icon() {
echo -n "$1" | nc -4u -w0 localhost $PORT
}
reset_icon() {
if [ "$INITIAL_COLOR" != "" ] && [ "$INITIAL_COLOR" != "none" ]; then
set_icon "$INITIAL_COLOR"
fi
}
main
@rtio
Copy link

rtio commented Oct 3, 2025

I made a few updates on this script to account for text changes. The gist file: https://gist.github.com/rtio/66b748b148e31ab4dc4b7136f58ab391

@mcsf
Copy link
Author

mcsf commented Oct 3, 2025

@rtio: Oh wow, I haven't thought about this script in 8 years. :)

I'm glad it was somehow useful. Thanks for the follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment