Textexpander markdown snippets1/29/2024 Snippets could also run on the iOS version whereas AppleScript andĪs an initial foray into using JavaScript snippets on my iOS devices Iĭecided I’d try recreating one of my existing snippet groups. The exciting thing to me however was that the JavaScript based Shell script based options such as BASH, Perl and Python (to name just aįew). That the previous OS X snippets could take advantage of AppleScript, or At first this may appear unremarkable given That brought a particularly interesting new feature. (But you’ll have more fun if you do.TextExpander: Clipboard Snippets Using Javascript There is so much repetition in business writing, especially correspondence, you’ll get your money’s worth from TextExpander even if you never exercise the AppleScript parts. I should mention that despite my love of script-driven snippets, David and Katie are exactly right when they say that TextExpander’s greatest value comes from simple, text-only snippets. What would be really nice is if these could be put into a popup menu, but TextExpander doesn’t allow that much magic yet. Those could be nested just like furl: (%snippet: 1url%) I have snippets that will get the URLs of the first through the sixth tabs (counting left to right) of the frontmost Safari or Chrome window. Similar snippets can use the URLs of other tabs. Maybe you don’t want to link to the current tab. All you need to type is the abbreviation and the link text. No context shifting, no fiddling with the clipboard, and a clean fill-in interface. When this is invoked, you see a much cleaner interface with the desired URL already in place: Where the thing in the parentheses is a call to my furl snippet. The content of this snippet is (%snippet: furl%) The best way to use a fill-in for the link text is this way: If you look through the popup menu that shows the TextExpander variables you can embed in a snippet, you’ll notice that all of your previously defined snippets are available, which means you can nest one snippet inside another. Unfortunately, TextExpander shows you the whole script while you’re doing the fill-in: Which would use a single-line TextExpander fill-in to get the link text. In fact, that last line could be written this way, applescript:ġ8: get "(" & fURL & ")" Not only can you use it to run scripts, but the output of those scripts will then be interpreted as TextExpander variables. This, by the way, is why TextExpander is such a great tool. No context shifting, no fiddling with the clipboard. So this snippet gets the URL, creates the Markdown inline link and positions the cursor right where you want it to type the link text. This is the TextExpander code for “put the cursor here after the expansion,” which is exactly what happens when this snippet is run. The cool part, though, is the %| inside the brackets. Where what’s inside the parentheses is the URL of the current page. It returns a string that looks something like this () These lines were stolen directly from my trusty furl snippet, whose history can be traced back to this old AppleScript I used to invoke through Quicksilver. Lines 1-16 get the URL of the current page in either Safari or Chrome. With a little AppleScript, all he’d need is Step 5.Īnd here’s the AppleScript it uses: applescript:Ģ: set numSafari to count (every process whose name is "Safari")ģ: set numChrome to count (every process whose name is "Google Chrome")ħ: tell application "Safari" to set fURL to URL of front documentġ1: set frontIndex to active tab index of front windowġ2: set fURL to URL of tab frontIndex of front window He saves a little time by keeping the ⌘ key pressed through some of the steps, but there’s still too much context shifting and too many repeated keystrokes.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |