design for style
Install Snippits for text replacement on Kubuntu Gutsy
One of my favorite sites, Lifehacker, ran an article on a text replacement tool for Linux called Snippits a day or two ago. Basically, you type in a small bit of text, like "sig" and hit a key combination and the Snippits program looks up the text you've designated to replace that and it swaps it into place. Very nice. And very timely. I'd had a conversation with a friend the day before about how much I wanted that functionality.
Note: Windows folks, check out Lifehacker's own Texter.
Snippits relies on Ruby and so there are a few dependencies required when installing it. Lifehacker provides instructions, but I hit a few bumps along the way.
Following are the steps I took to install Snippits on Kubuntu Gutsy Gibbon.
At the command line, enter:
sudo apt-get install build-essentialIf this prompts you to insert your Kubuntu install CD, and you don't have it handy, you'll need to comment out the line mentioning the CDROM in your sources.list. Do the following:
sudo kdesu kate /etc/apt/sources.listor for seasoned pros
sudo vi /etc/apt/sources.listThe CDROM source is usually in the first line.
Now this ought to work:
sudo apt-get install build-essentialNext, install the other dependencies:
sudo apt-get install ruby ruby1.8-dev rdoc rubygems libruby-extras xautomation xsel aspell libaspell-dev aspell-enNow install Snippits:
sudo gem install snippits[Removed section about adding Snippits to the path. Gems takes care of this. - mls 2008-02-03 AM]
[Reinstated section about adding Snippits to the path after feedback, and a reboot of my machine meant that Snippits stopped working without it. - mls 2008-02-03 PM]
The Lifehacker instructions, and the developer, Ben Kudria, say you shouldn't have to do this, but, well, I did. Add the Gems bin folder to your path in ~/.profile:
export PATH="$PATH:/var/lib/gems/1.8/bin"(You may need to start a new terminal session and/or reboot for the path settings to take effect.)
Next:
sudo mkdir ~/.snippits[Removed unnecessary info about creating a "do" snippit, as Ben Kudria pointed out it's unnecessary. There's a built-in "keyword" snippit. I've made additional edits below to reflect this. To view the other built-in snippits, once you have everything working, enter "builtin" as a keyword. Thanks for the clarifications, Ben! - mls 2008-02-03]
Now to set your keyboard hotkey to trigger the text replacement action.
In KDE, System Settings > Accessibility > Input Actions > New Action (button). In the General tab set the "action name" to Snippits (or whatever identifier you want). Set the "action type" to Keyboard Shortcut -> Command/URL (simple). Then under the Keyboard Shortcut tab, click the button and set a key combination. I use Win + s. Lastly, now, under the Command/URL Settings tab, set the "command/url to execute" to: ks keyword.
So, time to create a keyword and replacement pair:
sudo kdesu kate ~/.snippits/sig) or for seasoned pros
sudo vi ~/.snippits/sig) In the file enter an email signature (as this is our example). Now save the file sig (without an extension) in your ~/.snippits directory. Open up your email editor of choice and type sig and then hit your hotkey combo (for me Win + s), and bask in the joy of text replacement.
Read through all this and still don't know what Snippits does? Watch this:
Read more on advanced usage of Snippits at Lifehacker.com.
You can also visit the Snippits page on the developer's site at http://ben.kudria.net/code/snippits. (Cool fact: Ben Kudria is a Drupal user!)

w00t!
+1 Thanks for the walkthrough! I had been following the Lifehacker tutorial and was finding that it wasn't working as well (must have been for Ubuntu - but I am running Kubuntu). My productivity level just got a shot in the arm with the time saved not having to track this down!
updates
Snippits 0.5.2 has been released. If you've previously installed Snippits and have an earlier version, you can update it with the following command:
sudo gem update snippitsThanks for the writeup.
Great guide! Thanks for the writeup - I found it a bit late, though. :)
I've been hacking on the next version, with some improvements. As soon as I'm done fixing all the new bugs I'll probably push a release - got a lot more in store, too!