Skip to content

Instantly share code, notes, and snippets.

@wilhelm-murdoch
Last active October 22, 2021 13:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilhelm-murdoch/b92b692673033faa3acb0da3758decdd to your computer and use it in GitHub Desktop.
Save wilhelm-murdoch/b92b692673033faa3acb0da3758decdd to your computer and use it in GitHub Desktop.
Convert text to "spongebob' format from your command line ...
#!/usr/bin/env bash
set -eo pipefail
[[ -n "${VERBOSE}" ]] && set -x
read text
while [[ $index -lt "${#text}" ]]; do
swap=$(( $RANDOM % 10 ))
char="${text:$index:1}"
if [[ "${swap}" -lt 5 ]] ; then
echo -n "${char}" | tr '[[:lower:]]' '[[:upper:]]'
elif [[ "${swap}" -lt 3 ]]; then
echo -n "${char}" | tr '[[:upper:]]' '[[:lower:]]'
else
echo -n "${char}"
fi
index=$(( $index + 1 ))
done
echo
@wilhelm-murdoch
Copy link
Author

wilhelm-murdoch commented Oct 14, 2021

Usage:

  1. Save to your local file system: ${HOME}/bin/spongebob.
  2. Grant the file permission to be used as an executable: chmod a+x "${HOME}/bin/spongebob"
  3. Ensure it's visible on your system's $PATH.
  4. Now run echo 'This is SpongeBob text!' | spongebob from anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment