TextExpander logo TextExpander SmileOnMyMac logo
 

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.

 
 
© 2006-2010 SmileOnMyMac, LLC. All rights reserved.
SmileOnMyMac and TextExpander are trademarks of SmileOnMyMac, LLC.