Dummy text at your fingertips

Sometimes I find myself in need of more than just the block of Lorem Ipsum text that magically appears from typing “lorem” and hitting tab in Textmate. Sure, I could use a handy widget, but flipping back and forth from the dashboard gets tiresome after a few iterations.

A textmate command

With a few lines of ruby, I built a rough Textmate command that prints a random sentence from a paragraph of filler text. It looks like this:


#!/usr/bin/env ruby -wKU

# Paragraph of sentences to pull from
copy_to_use = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec leo tellus, ornare ac, molestie eu, suscipit non, urna. Sed in felis. Vivamus justo dui, tempus vel, blandit sed, placerat sit amet, nunc. Praesent rhoncus quam nec risus. Etiam eu nulla eu sapien ultrices hendrerit. Nulla et metus ac ipsum vulputate varius. Nullam nec mauris nec nulla ornare fermentum. In a libero. Aliquam erat volutpat. Ut ornare. Ut nec libero a metus posuere tincidunt. Sed sed arcu. Maecenas lobortis, massa sit amet convallis eleifend, neque erat commodo sapien, ut varius dolor quam vitae lorem. In tellus. Nam eu dolor. Aliquam erat volutpat. Nulla eu arcu. Mauris dignissim, neque egestas rhoncus feugiat, magna diam varius elit, ut hendrerit diam sapien vel velit. Donec lobortis. Aenean mattis turpis sed odio. Donec suscipit lectus quis felis. In hac habitasse platea dictumst. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nam interdum. Nulla facilisi. Donec facilisis. Phasellus tristique. Vestibulum pellentesque felis nec dui. Mauris dolor odio, mollis et, sollicitudin vitae, facilisis sed, enim. Duis velit. Nullam a augue. Aliquam erat volutpat. Aenean ut magna nec dui congue congue. Maecenas sagittis nisl ut neque. Nam facilisis urna sed purus luctus congue. Morbi interdum, ligula non ullamcorper faucibus, purus ipsum fermentum neque, in viverra nisi ante at turpis. Ut molestie gravida sapien. "

# Split by period-space into an array
sentence = copy_to_use.split(". ")

# Randomize the array
random_sentence = sentence.sort_by{ rand }

# Pull a sentence off the top and punctuate
print random_sentence[0] + "."

To add this command, paste the above into a new command in the bundle editor, setting input to “none”, output to “insert as text”.

bundle settings

Choosing a tab trigger of your desire will get you a command that is ready to spit out random nonsensical sentences.

System wide lorem ipsum – it’s everywhere!

Shortly after that was done, I came across this post from HeySage regarding using tools like TextExpander to generate static blocks of text system wide. This would be similar to TextMate’s lorem snippet mentioned above, but would let you put the text in browsers and other applications. But what if I wanted something a little more dynamic?

The latest version of TextExpander has Applescript support. By saving the above command as a file, and setting the snippet content type to “Applescript” in TextExpander, we can put the do shell script command in Applescript to good use:

do shell script "/usr/bin/ruby  /Library/ScriptingAdditions/ipsum.rb"

I had to hunt a bit to find out how to set the content type, but after that it looked something like this in TextExpander:

textexpander snippet creation screen

For lack of a better place, I stuck the script file in the ScriptingAdditions folder.

Caveat dolor

It’s important to remember that using fake text has it’s downsides. In their book Getting Real (if you haven’t read it, I highly recommend it), the folks at 37signals give some good reasons why you shouldn’t use lorem ipsum text:

“Dummy text means you won’t see the inevitable variations that show up once real information is entered. It means you won’t know what it’s like to fill out forms on your site. Dummy text is a veil between you and reality.”

Just because you can insert random string of text everywhere, it doesn’t mean you should. With great power comes great responsibility (what, you don’t take your values from people in tights?).

That said, dummy text can be a valuable tool. It has certainly been helpful, even by it’s very existence, in illustrating the power of other tools, such as those discussed here.

12 Comments