One-Liner Persistent Rick Roll on Mac

· Updated · 3 min read

That feeling that you get when Rickrolling someone, is bliss. But what if you could Rickroll someone repeatedly, obscurely, and above all, absolutely annoyingly?

I am not responsible for what you do with the information on this page and website. Executing one-liners, scripts, or code that you did not write or do not understand is risky. Executing code on another person’s computer without their consent is malicious, and may be illegal.

Launching the Rickroll

The below one-liner triggers a wait condition for 1 hour, then begins an infinite loop of opening a webpage in the default browser, and waiting a random amount of time between 30 seconds and 3 minutes. The process is disowned, allowing a terminal where this is executed to be closed.

$(sleep 3600; while true; do open -u "https://archive.org/download/rick-roll/Rick%20Roll.ia.mp4"; sleep $((30 + RANDOM % 150)); done) & disown

What Each Command Does

Terminating the Disowned Process

The parent ‘zsh’ process has to be terminated to break the Rickroll loop.

sleep_parents=$(ps -Ac -o ppid,comm | awk '/sleep/ {for(i=1; i<NF; i++) {print $1 | "xargs ps -p"}}'); echo "${sleep_parents}"
# PID TTY           TIME CMD
# 10010 ttys002    0:01.00 /bin/bash /usr/local/something/else
# 10101 ttys002    0:00.01 -zsh

zsh_parent_pid=$(echo "${sleep_parents}" | awk '/zsh/ {print $1}'); echo "${zsh_parent_pid}"
# 10101

kill -9 "${zsh_parent_pid}"

What Each Command Does

Get Parents of Sleep Processes

Get ZSH Parent Process ID

Terminate Parent Process

FAQ

In The Case It’s Still Running

Save everything you were working on, and reboot.

Why Would You Create This

  1. For the lulz.
  2. It’s fun.
  3. It’s educational.
  4. It’s potentially malicious.
  5. It’s useful for reminding your colleagues that they shouldn’t walk away from their computer without locking it. But maybe use a picture of a unicorn, instead of an autoplaying movie.