Topic: https://brettterpstra.com/2010/05/07/textexpander-experiments/
hide preview

What's next? verify your email address for reply notifications!

Thomas Hanke 14y, 29d ago

Hi Brett,

I've been using TextExpander for some years, but only recently began to use it for more than vanilla snippets. Since I've recently began to use Markdown seriously, your scripts are highly welcome. Thanks!

Still, I've got a question on the "Markdown Link" script. Perhaps, it even useful to someone else.

I've spent some time trying to combine it with a family of simple AppleScripts to get Safari's URL, title, selected text with some formating into the clipboard. (what fun I had two weeks ago to find out how to get selected text from Safari...)
Before I mangle up the chars, I play safe and present it stripped-down without quotes:
set w to front window
set theTitle to name of w
set theURL to URL of document of w
set the clipboard to theURL & Quote & theTitle & Quote
end tell

The best I got to is to run the AppleScript with Apptivate (or some other minimalistic Launcher), then type the abbreviation for your script. Well, I'm down to 4 key strokes, but have to invoke the script separately.
Any hint how to get an Apple Script (using osascript, I guess) running inside the Ruby Script inside TextExpander would be highly appreciated.
I've had no luck with osascript, but this may be due to my (lack of) proper escaping talent. Just running the scripts in TextExpander as snippets didn't work either, but I can't tell what goes wrong inside TextExpander.
Since the AppleScript just fills the clipboard, there's no interaction with the outer script or TextExpander. I haven't been able to find any detailed info on Smile's site.

Thomas

remark link
hide preview

What's next? verify your email address for reply notifications!

Thomas Hanke 14y, 29d ago

Ok, just answered it myself to a good degree. Should I mention that I just installed your Weblogzinc bundle two hours ago and haven't checked all components. Wow, TextMate (and you) are getting more and more impressive ;-)

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Brett 14y, 29d ago

Cool. In case you need it, you just need to use a "heredoc" to call osascript:

 def ruby_function(var)
%x{osascript <<'APPLESCRIPT'
tell application "Something"
do something with #{var}
end tell
APPLESCRIPT}
end
hide preview

What's next? verify your email address for reply notifications!

Jeff 14y, 40d ago

Thanks for the snippets! Very creative. These TextExpander posts are great.

I ran into an issue using some of them with Ruby 1.9, but I got them working by changing the call to the Ruby interpreter to just #!/usr/bin/env ruby and switching the syntax of the case statements so they use "then" instead of a colon and a newline. For example, from the Markdown reference list snippet:

name = case parts.length
when 1,2: parts[0]
else parts[1]
end

Becomes:

name = case parts.length
when 1,2 then parts[0]
else parts[1]
end
remark link
hide preview

What's next? verify your email address for reply notifications!

Brett 14y, 29d ago

Sorry for the delayed reply, but thanks for the tip. Sounds like a lot of my stuff is going to break when I finally get around to running 1.9 in anything other than RVM.

hide preview

What's next? verify your email address for reply notifications!

Eddie 14y, 43d ago

The hyphenation script is really useful for replacing spaces with dashes in file names on the fly. Thanks!

remark link
hide preview

What's next? verify your email address for reply notifications!

Brett 14y, 43d ago

Sure thing! That's actually exactly why I originally wrote it :). I have one that removes punctuation at the same time, if you ever need shell-friendly filenames.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Eddie 14y, 43d ago

Would love that.

Today, I found another use case for the hyphenation script: fast editing permalink slugs. I have an insatiable need to fiddle with my blog post titles -- often right up until the time they go live. Sometimes I leave the slugs alone, but sometimes I have to edit them so it all makes sense (to me anyway).

hide preview

What's next? verify your email address for reply notifications!

davejorr 14y, 73d ago

Brett,
Here is one for you! Make a text expander that pulls the contacts name from address book to start an email.

Example:
I want to send an email to David.
1. I open mail
2. In To: I type David and it finds me in my address book.
3. I Type (expander short-cut) i don't know "hfn"

The result would be: Hello David,

remark link
hide preview

What's next? verify your email address for reply notifications!

Brett 14y, 71d ago

Intereting idea, I'll give it a shot when I get a chance!

hide preview

What's next? verify your email address for reply notifications!

Donald Jenkins 14y, 154d ago

Brett, It just occurs to me that it would be nice if the bit.ly snippet could be modified to create the short URL in one's own account. What do you think?

remark link
hide preview

What's next? verify your email address for reply notifications!

btadmin 14y, 153d ago

Here, I made you something :).

hide preview

What's next? verify your email address for reply notifications!

Norm 14y, 303d ago

I'm new to textexpander. Your tips really show what is possible. I decided to start off with a simple signature. I wanted to add small social media icons that would click through to my various pages (flickr, twitter, etc.). Is it possible to add a hyperlink to an image embedded in a snippet?

remark link
hide preview

What's next? verify your email address for reply notifications!

ttscoff 14y, 303d ago

If I'm not mistaken, you should be able to link the images a rich text editor (like TextEdit in Rich Text mode) and copy them into a rich text snippet in TextExpander. Just insert the image into TextEdit, select it, and type ⌘K to bring up the link dialog. Set the link, select all and copy it into TextExpander. I just tested it and then used the snippet in an email to myself and the link works like a charm.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Norm 14y, 303d ago

THANK YOU! I'll give that a try, sounds like a simple solution :)

hide preview

What's next? verify your email address for reply notifications!

Donald Jenkins 14y, 317d ago

Congrats: this is exactly what I've been wanting, you're spot on as usual Brett.

remark link
hide preview

What's next? verify your email address for reply notifications!

ttscoff 14y, 317d ago

Thanks, Donald! If you've got any suggestions for new snippets, I'm always up for a challenge :).

hide preview

What's next? verify your email address for reply notifications!