Created
February 1, 2025 19:47
-
-
Save rmtbb/0b0850dbf67bbc04eca7f1ff56af4cea to your computer and use it in GitHub Desktop.
stayup: a fun one-liner tool that does more than just keep your Mac awake using `caffeinate -d -u`. It adds a bit of personality by displaying two synchronized, animated ASCII eyes
This file contains hidden or 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
caffeinate -d -u & pid=$!; trap "kill $pid" EXIT; blink=$(( $(date +%s) + 10 + RANDOM % 21 )); nextdir=$(date +%s); px=$((RANDOM % 3)); py=$((RANDOM % 3)); while sleep 0.5; do now=$(date +%s); if [ $now -ge $nextdir ]; then px=$((RANDOM % 3)); py=$((RANDOM % 3)); nextdir=$((now + 2 + RANDOM % 3)); fi; if [ $now -ge $blink ]; then clear; echo -e " +-------+ +-------+"; echo -e " |-------| |-------|"; echo -e " |-------| |-------|"; echo -e " |-------| |-------|"; echo -e " +-------+ +-------+"; echo -e "\nStay up till you wake up\nPress Control + C to exit"; sleep 0.2; blink=$(( $(date +%s) + 10 + RANDOM % 21 )); fi; clear; echo -e " +-------+ +-------+"; for r in 0 1 2; do row=""; for c in 0 1 2; do if [ $r -eq $py ] && [ $c -eq $px ]; then row="${row}\033[107m\033[30m@\033[0m"; else row="${row}\033[107m \033[0m"; fi; done; echo -e " | ${row} | | ${row} |"; done; echo -e " +-------+ +-------+"; echo -e "\nStay up till you wake up\nPress Control + C to exit"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
stayup is a fun one-liner tool that does more than just keep your Mac awake using
caffeinate -d -u
. It adds a bit of personality by displaying two synchronized, animated ASCII eyes that:Keep your computer awake:
Utilizes macOS’s built-in
caffeinate
command with the-d -u
options.Animate synchronized eyes:
Both eyes always look in the same random direction. The pupils update every few seconds, giving the impression of changing gaze.
Blink periodically:
The eyes blink every 10–30 seconds for a brief 0.2-second "closed" display.
Display helpful messages:
At the bottom of the animation, you'll see:
Stay up till you wake up Press Control + C to exit
This tool is made by Remote BB and is perfect if you’re looking for something more entertaining than just running
caffeinate -d -u
.How to Use
Open your Terminal.
Copy and paste the following one-liner into your Terminal:
Enjoy the Animation!
Once executed, stayup will keep your Mac awake while you enjoy the animated ASCII eyes. The synchronized eyes will randomly change their gaze direction and blink at intervals, while the messages at the bottom remind you to stay awake and how to exit.
To Exit:
Simply press Control + C in your Terminal.
Requirements
macOS with the caffeinate command available.
Bash shell (or a compatible shell that supports the syntax used).
Set stayup as a standalone command for quick use
Open your Terminal and create a new file named stayup in a directory that's in your PATH (for example, /usr/local/bin):
In the text editor that opens, paste the following code:
If you’re using nano, press Ctrl + X, then Y to confirm, and Enter to save the file.
In Terminal, run:
Now you can simply type:
The one-liner will execute, keeping your Mac awake while showing the animated ASCII eyes. To exit, just press Control + C.