Random responses with aText

If you're using Mac's software aText for text expansion you will probably like this little snippet.

You have to create it as a Shell Script and it allows you to print a random message every time you expand it.

#!/bin/sh # Keep this updated when you add or take away quotes on the case list num_greetings=4 # Generate a random quote number variable, 'rand' rand=$[ ( $RANDOM % $num_greetings ) + 1 ] case $rand in #BEGIN CASE 1) greeting="Hello, how may I help you?";; 2) greeting="Hi, how can I help you?";; 3) greeting="Hello, how can I help you?";; 4) greeting="Hello, what can I do for you?";; esac # END CASE # Display the random quote from case statement, and format it to line wrap at 80 characters echo $greeting
Code language: PHP (php)

About Ricard Torres

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

Add <code> Some Code </code> by using this tags.