October 21, 2015

Going Random with TextExpander

As a tester, I sometimes have a need for a random word. For example, I may need a unique word for creating a new account in my system. Using the Shell Script feature in TextExpander now makes it easy to add a random word whenever I need to.

Here are the simple steps to create a TextExpander Snippet so that you can instantly insert a random word whenever you need it:

random word
  1. Open up TextExpander and create a new Snippet.
  2. Change the script Content type to 'Shell Script'
  3. Enter in the following code:
    lines=$(cat $WORDFILE | wc -l);
    sed -n "$rnum p" $WORDFILE | perl -pe 'chomp'
  4. Click on the 'eye' to get a preview to make sure that it works.
  5. Enter in 'Random Word' as the Label.
  6. Enter 'rrandom' as the Abbreviation. (Makes it easy to remember!)

The root dictionary, /usr/share/dict/words as my random source library is good choice since their are 235,886 words available.

There are many ways to get a random word, I selected using the above method since it seems to be the quickest way. If you know of a better option, let me know!


Add your Comments

Feel free to leave a comment about this post.

- Feel Free to add HTML to your comment!