ShitScript/shell.nix
2025-08-11 01:40:01 -04:00

68 lines
1.2 KiB
Nix

{pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
pkgs.cbonsai
pkgs.cmatrix
pkgs.neo-cowsay
pkgs.fortune
pkgs.nyancat
pkgs.coreutils
pkgs.sl
pkgs.asciiquarium
pkgs.pv
];
shellHook = ''
LAST=""
STIME=120
programs="cmatrix cbonsai nyancat fortuneCow otherCow train fish"
trap 'stty sane; tput cnorm; clear' EXIT
while true; do
while :; do
choice=$(echo "$programs" | tr ' ' '\n' | shuf -n 1)
[ "$choice" != "$LAST" ] && break
done
LAST="$choice"
clear
tput sgr0
case "$choice" in
cbonsai)
cbonsai -l -t 1 & pid=$!
( sleep "$STIME" && kill $pid ) & watcher=$!
wait $pid 2>/dev/null
kill $watcher 2>/dev/null || true
;;
cmatrix)
bash -c "cmatrix -u 4 & pid=\$!; sleep $STIME; kill -INT \$pid; wait \$pid"
;;
nyancat)
timeout "$STIME" nyancat
;;
fortuneCow)
fortune | cowsay
sleep "$STIME"
;;
otherCow)
fortune | cowsay --random
sleep "$STIME"
;;
train)
sl
;;
fish)
asciiquarium & pid=$!
( sleep "$STIME" && kill $pid ) & watcher=$!
wait $pid 2>/dev/null
kill $watcher 2>/dev/null || true
;;
esac
sleep 1
done
'';
}