Last active
April 6, 2024 21:52
-
-
Save Exponential-Workload/74b56ffc23f3c6e17970c1458006db14 to your computer and use it in GitHub Desktop.
watch.sh: A simple script for getting up-to-date command output faster, without stdout flickering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
set -eax | |
# Do not run this with untrusted argv! | |
# Usage Example: ./watch.sh curl -fsSL http://66117b5a7483e49ba3af.functions.localhost/log | |
A="$RANDOM" | |
B="$RANDOM" | |
while true; do | |
A="$($@)"; | |
if [[ "$B" != "$A" ]]; then | |
echo -e "\x1b[H\x1b[2J\x1b[3J$A"; | |
B="$A" | |
fi; | |
sleep "${INTERVAL:-0.2s}"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment