We have relaunched: What's new at ZDNet Asia?

Expanding text with Snippits

Summary

Find out the basics on Snippits, a Linux-based text-expanding tool similar to Typinator or TextExpander for Mac.

Events

Microsoft MSDN/Developer Event
25 Mar 2010

One Marina Boulevard, Microsoft Singapore

IT Architect Regional Conference Singapore 2010
20 - 21 Apr 2010

Singapore Management University, Singapore

The Internet Show 2010
21-22 Apr 2010

Suntec Singapore

Perhaps one of my favorite features or tools with the Mac OS X operating system is the ability to use text-expanding programs such as Typinator or TextExpander.

These programs allow you to type a keyword, regardless of the focused application, and have it expand into a custom string, set of text, or image. These text-expanding tools are a constantly-used time saver.

On Linux, there is nothing as comprehensive as Typinator or TextExpander on the Mac. There is one program that comes close, but is not as fluid or elegant as the Mac equivalents.

The program is called Snippits, and it also expands text based on predefined keywords. Snippits is a Ruby program and requires a little bit of effort to install, depending on the Linux distribution in use.

On Debian and Ubuntu it is easier to install because one of the prerequisite packages, xautomation, is readily available. On Mandriva Linux, the package is not available and so must be compiled from source, which is easy enough to accomplish.

With any distribution, at the very least you will need to install aspell and its development files; Ruby and its development files; and also whichever package provides Ruby's gem support. On a Debian system, this can be accomplished by executing:

# apt-get install ruby ruby1.8-dev rdoc rubygems libruby-extras 
xautomation xsel aspell libaspell-dev aspell-en build-essential

On Mandriva Linux, because xautomation must be compiled from source, the following is required. Note the commands on a # prompt are executed as root, whereas those with a $ prompt should be executed as a regular user. As a result, the below is somewhat abbreviated; you may elect to use sudo (if you have configured it appropriately) or su to the root user when required.

# urpmi ruby-RubyGems ruby-devel aspell-devel 
aspell-en x11-devel png-devel
$ curl -O -L http://hoopajoo.net/static/
projects/xautomation-1.02.tar.gz
$ tar xvzf xautomation-1.02.tar.gz
$ cd xautomation-1.02
$ ./configure && make
# make install

Once this is done, the Snippits gem must be installed and Ruby configured to use Rubygems by modifying the ~/.bashrc startup file:

$ echo 'export RUBYOPT="rubygems"' >>~/.bashrc && source ~/.bashrc
# gem install raspell
# gem install snippits

This will install the RASpell gem which is required by the Snippits gem, and then compile and install the Snippits gem.

Once this is completed, you can test Snippits. Snippits are stored in the ~/.snippits/ directory; each file is its own snippit. For instance:

$ mkdir ~/.snippits
$ echo "this is a snippit test" >~/.snippits/test
$ snippit test
this is a snippit test
$ ks test
this is a snippit test
$ this is a snippit test

The snippit [name] command outputs the contents of the file named [name]; in this case ~/.snippits/test. Using the ks command, the contents are not only outputted, but are also used as input for the next command.

Snippits allows for a lot of extra modifiers to really manipulate text, such as {enter} to type an enter keystroke or {tab} to enter a tab keystroke. For instance, if a snippit were defined in ~/.snippits/pstest as:

ps aux|grep {cursor}|wc -l

Executing ks pstest would result in the above being printed on the command-line with the cursor being positioned where the {cursor} string is located, exactly where you would want the cursor to be to type what to grep for.

The above has only illustrated Snippits' use for command-line usage. It is possible to bind the ks command to a global hotkey in KDE or GNOME which would allow for Snippits to be used in any application.

The drawback here, compared to the Mac-equivalent programs, is the need for the hotkey to begin with as there doesn't seem to be a way to make Snippit automatically transform text based on the appearance of the keyword--perhaps in a future version. The application is under active development and definitely looks to have promise.

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment
Transform your business interactions with real-time voice, video and telepresence solutions.
Tech Vendor: Cisco

ZDNet Asia Live

whatever little understanding I have we 'll only progress toward end of the world if we use HPCs to lenthen life of human being. Huma...

3 hours 16 minutes ago by abhi32002@gmail.com on High computing promises elixir of life

Thanks for the knowledgeable article on SDDs. Allas...when all this reasearch will happen in Indian Universities. Hope the new bill on Fo...

3 hours 29 minutes ago by abhi32002@gmail.com on APAC HPC users eye solid-state drives

It was a good article. This brings a good opportunity for Indian IT firms to come up with new solutions in this field. HPC can become a b...

3 hours 47 minutes ago by abhi32002@gmail.com on High computing most-wanted job in Asia

COL KR DHARMADHIKARY(RETD) its very late to reply the link, but if it is still alive and looking for opportunity, i would like to know th...

7 hours 45 minutes ago by deb021280 on Education takes off in rural India, helped by PCs

It was just a matter of time until google was marginalised anyway. I'm afraid this will be forgotten in China very quickly. Still, it...

9 hours 50 minutes ago by robinsmith on Report: Google to leave China on April 10

High performance computing (HPC) most-wanted job in Asia http://bit.ly/9vFC3i (via @zdnetasia) #singapore

He doesn't care if her shoes are of glass, All he wants to see is a huge rack and nice a*s. Sleeping beauty's not awoken by true ...

10 hours 18 minutes ago by warlowdavies on One pair of 3D glasses to rule them all

RT @zdnetasia: EMC COO, Pat Gelsinger, on bridging gaps in the organization and its cloud ambitions in Asia. (cont) http://tl.gd/i5jjd

EMC COO, Pat Gelsinger, on bridging gaps in the organization and its cloud ambitions in Asia. http://bit.ly/9etOZW

Spoke to EMC COO, Pat Gelsinger, earlier, and here's the account of the interview: http://bit.ly/9etOZW

11 hours 39648 seconds ago by kevinzdnetasia on topsy

Asian SMBs need to pay more attention to disaster recovery planning http://bit.ly/bDet08 via @zdnetasia

Asian SMBs need to pay more attention to disaster recovery planning http://bit.ly/bDet08

Experts: social media guidelines good for upcoming Youth Olympic Games, but focus on cooperation, not enforcement. http://bit.ly/d9M0BQ

11 hours 32 minutes ago by zdnetasia on topsy

Asian SMBs need to pay more attention to disaster recovery planning http://bit.ly/bDet08

11 hours 33 minutes ago by kevinzdnetasia on topsy

ZDNet Asia features IBM collaboration roadmap story from LCTY Singapore - http://bit.ly/9CuSbZ #lotusknows

12 hours 27 minutes ago by lotusknows on topsy

[TECH] URL Shorteners slow Web redirection. - http://bit.ly/bySnWK @zdnetasia

URL shorteners are great but they can slow web redirection & you pray it would never go down http://bit.ly/bySnWK via @zdnetasia

Temasek Holdings eyeing tech stocks, indicating optimistic outlook on IT sector. http://bit.ly/aM7VwU

URL shorteners slow Web redirection. http://bit.ly/bySnWK

Chinese agencies cry foul over Google. http://bit.ly/by6rwV

Philippine antipiracy drive focuses on enterprises. http://bit.ly/aWryDC

Gartner: China to become world's fastest-growing enterprise software market. http://bit.ly/bqJTtb

all of sg's isps have been practising compulsory invisible proxy for all home subscribers at their backend since many years back alre...

1 day 28 minutes ago by melvinchia on Web filters mean bad news for business

it is not to good for china.
Proactol

1 day 13 minutes ago by nathonastle on Chinese ad partners beg Google for information

RT @zdnetasia: HP touts new products and management and productivity tools to address business computing pain points. http://bit.ly/dudgA6

For those with a computer science background, or interested in the high performance computing scene: http://bit.ly/9vFC3i

HP touts new products and management and productivity tools to address business computing pain points. http://bit.ly/dudgA6

Very good explanation of JMX

2 days 18 minutes ago by Babith B on Managing applications with JMX

The reaction to a report issued Tuesday by Flurry Analytics managed to completely overlook some interesting news--the Android-based Motorola Droid outsold the original iPhone over the same period of time following their respective launches--to focus instead on the sales numbers for the Nexus One.

2 days 22 minutes ago by lonemavericks on diggs

Another ZTE story....

2 days 24 minutes ago by Moderate Your Greed on Philippines opens bid for final 3G license

We at www.fifosys.com have also seen a growth in IT outsourcing and anticipate it as a growing field.

2 days 57 minutes ago by sarah Jane on Companies' outsourcing spend to increase

I agree with you. The iSiVaL is super portable and TVs can't expand their image size. I recorded a video that might bring some ideas to...

3 days 28 minutes ago by Jesse B Andersen on Buying a projector? Try an LED TV instead

hermm... he deserved it.. he shud not talk abt sensitive things like tat, well, he shud think twice before saying all those things, event...

3 days 6 minutes ago by ... on Facebook user charged in Malaysia

Password manager tools are potential security threat. Criminals who hack into the computer can use the password manager to log onto any s...

3 days 6 minutes ago by ohanae on What defaults should random password generators use?

I've found the cross platform utility unetbootin to be rather handy for this kind of thing as well.

3 days 40 minutes ago by Jim on Use Live USB Creator to install Fedora 12 from a USB stick