![]() The line where we define the list of snippets is really all you’ll need to edit when you customize this. It’s not terribly important that you understand all the guts of what’s going on here. This is where TextExpander listens for script output. The last line chooses one element from our list at random and writes it to the system’s standard-out interface (STDOUT). The third line defines a collection of snippets (using their embedded-snippet syntax so we can edit the snippets themselves without monkeying around with this script). The next line imports the `random` and `sys` modules. The first line, known as the “shebang” line, tells the shell to run the script using the Python interpreter. If you’ve written python code before, this is pretty straightforward. Next, I created a new snippet and set it to type “Shell Script”. So, I started with the following snippets: ![]() Luckily, TextExpander provides a way to embed snippets in other snippets. Here’s how I did it.įirst, I wanted to be able to edit the “candidate snippets” - that is, the collection of snippets from which a random selection would be made - without having to edit the script itself. This particular capability is what helped me quickly (like, in under five minutes) implement the feature my friends wanted. Because we have access to the shell, we also have access to a whole host of full-blown programming languages from within TextExpander. ![]() Part of what makes TextExpander so badass is that, in addition to its normal text substitution capabilities, you can also have it run scripty things (either shell scripts or AppleScript). Thankfully, TextExpander can do this out of the box with a little scripting-fu. This is something I’ve thought about in the past, but had never given a whole lot of thought. In a nut, they want to be able to type ( using Shawn’s example) “ttypo” and have TextExpander choose a random snippet from a predefined list. A couple of buddies had mentioned on the Interblags that they wished TextExpander supported what they dubbed “random snippets”.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |