Created
May 2, 2024 02:08
-
-
Save rmtbb/853df767f28588462f17adcc2d437a81 to your computer and use it in GitHub Desktop.
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
nohup zsh -c 'while true; do voice=$(say -v "?" | awk "{print \$1}" | sort -R | head -1); say -v "$voice" "It is now $(date "+%l %M %p")."; sleep $((30 + RANDOM % 1971)); done' & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Time Announcement Prank: Announce the time at random intervals and voices.
to use Time Announcement Prank via Terminal:
to use Time Announcement Prank via curl:
Explanation of the Script
This prank command is designed to run a continuous loop in the background of a Unix-like operating system that periodically uses the
say
command to audibly announce the current time with a randomly selected voice. Here’s a breakdown of each component:nohup
:nohup
stands for "no hang up." It's used to run a command immune to hangups, with output to a non-tty. This means the command will continue running even if the user logs out or the terminal is closed.zsh -c
:'...'
) using the Z shell (zsh
). The-c
option allows passing a command as a string.while true; do ... done
:while true
, which means the loop will continue indefinitely becausetrue
always evaluates as true.voice=$(say -v "?" | awk "{print \$1}" | sort -R | head -1);
:say -v "?"
: This command lists all available voices for thesay
command.awk "{print \$1}"
: This usesawk
, a pattern scanning and processing language, to print the first column of the output, which corresponds to the voice names.sort -R
: Randomly shuffles the list of voices.head -1
: Selects the first entry from the shuffled list, which will be the random voice chosen for that iteration.voice
.say -v "$voice" "It is now $(date "+%l %M %p").";
:say
command to speak out loud. It uses the voice stored invoice
to announce the current time.$(date "+%l %M %p")
: This command is substituted with the current time, formatted to show the hour (%l
), minute (%M
), and AM/PM indicator (%p
).sleep $((30 + RANDOM % 1971));
:30 + RANDOM % 1971
calculates a random delay time whereRANDOM % 1971
produces a random number between 0 and 1970, which, when added to 30, results in a delay ranging from 30 seconds to 2000 seconds (or approximately 33 minutes).&
:Overall Function
This script continuously announces the time at random intervals using different voices available on the system. It's a practical demonstration of various shell scripting components like loops, random number generation, background execution, and command chaining.
The Antidote: Shut Your Computer Up
to use The Antidote via terminal:
to use The Antidote via curl:
More Info on the Antidote