| # Help: AppleScript Snippets and Shell Script Snippets ### AppleScript Snippets In the content format drop-down menu, choose "AppleScript" as the format type. In the content field, enter an AppleScript such as this one: -- Adjust greetingsList values to your preferred greeting set greetingsList to {"Sincerely", "Yours Truly", "Peace Out", "Have a good day", "kthxbai"} set listLength to count greetingsList set randomNumber to (random number from 1 to listLength) set selectedGreeting to item randomNumber of greetingsList return selectedGreeting ### Shell Script Snippets In the content format drop-down menu, choose "Shell Script" as the format type. In the content field, enter a shell script such as this one: `#!/usr/bin/perl print "Hello from Perl!\n";` Your shell script must have the “shebang” (#!) on its first line and that must specify the interpreter to be used for your script. Here is an example of a Unix shell script `#!/bin/bash echo "Hello from Bash!"` ### Nesting Script Snippets AppleScript snippets and shell script snippets can be nested within text snippets using the nested snippet macro %snippet:[snippet name]%. Example: if the AppleScript snippet above had the abbreviation "eend", you could use it in a text snippet: Dear Reader, Thank you for your feedback on my book. %snippet:eend%, - Author which would expand to: Dear Reader, Thank you for your feedback on my book. Have a good day, - Author or one of the other random choices in greetingsList. Feel free to share your cool scripts with us. For information on other macros used in TextExpander, see Date, Time, and Math Macros and Advanced Snippet Functions: Macros. |
| © 2006-2014 SmileOnMyMac, LLC, dba Smile. All rights reserved. TextExpander is a registered trademark, Smile and the Smile logo are trademarks of SmileOnMyMac, LLC, dba Smile. |