Improving snippits to handle the clipboard

So I’ve spend a little time from my life to get snippits to work. Initially I discovered this little gem through a lifehacker article (which also alerted me to texter for windows) but unfortunately I couldn’t get it to work with the guide included there or on the snippits readme. It just would not load on login.

Fortunately for me, a quick search revealed a guide in the ubuntu fora in which my question was answered. I needed to modify my path variable to include the location of the script. For some reason however this did not work whatever I did. This was even more annoying since my “exit” function of Ubuntu currently locks up my X-Session and the only thing I can do once I press it is to Ctrl-Backspace and restart it. Anyway, I tried various things (even the all classic windows trick, reboot) but nothing seemed to make my path export be accepted. Eventually, I was told that I should try to put it in my ~/.bash_profile file, and fortunately that worked.

Then I set to the task of making useful macros. Inserting a text string is pretty straightforward, you just have to create a file in your ~/.snippits directory which has a name equal to the text you want replaced, so for example you create a simple text file called “fyi” in there (no .txt extension) and inside you write “for your information“. Then if you write in any copy enabled program “fyi” and press your shortcut key, this will be transformed into the “for your information” text. Simple

Unfortunately, I discovered that because snippits eats your current clipboard, I could not use it to wrap links I copied from the address bar in my clipboard in bbcode or html. After asking around the forum however, I did manage to convince the thread author (by challenging him no less) to find out a way to do it. Specifically he used the xclip program to copy the current clipboard into a secondary clipboard and paste from there.

All you need to do to manage that is to install xclip sudo apt-get install xclip and then replace your normal “do” text file with a this:

<%`xclip -o -selection clipboard | xclip -i -selection secondary`%>{shift}{control}{left}{shift}c{control}{paste}

Then on the action you want to paste from the clipboard, you need to use this part:

<%= `xclip -o -selection secondary` %>

at the point that you want the clipboard pasted.

Here’s a little screencast I made as well. It might be a bit blurry but I’ll try to make a better version soon


One thought on “Improving snippits to handle the clipboard”

Comments are closed.