How do I give myself fast access to pasting some common strings?
Solution 1:
You can install autokey
with sudo apt-get install autokey-gtk
for the GTK+ version or sudo apt-get install autokey-qt
for the Qt version.
autokey
allows you to define abbreviations which when typed in anywhere in your xsession will expand to a defined phrase: E.g I defined an abbreviation xyy
for the phrase Thank you for your help. I ticked in the Always prompt before pasting this phrase option in the autokey
configuration. From now on, anywhere I type xyy
and hit a space, a small pop-up appears, which I can select with a down-arrow key and an ENTER and the typed xyy
is replaced with the phrase Thank you for your help.
If you don't tick in the "prompt before pasting" option then the abbreviation is replaced immediately after you hit space. You can also define scripts, like for inserting the current date.
I use autokey-gtk
on 12.04 which has a minor problem that the autokey
tray icon doesn't show up on the panel. To correct this just launch dconf-editor
and add 'Autokey'
to the Desktop->Unity->Panel->systray-whitelist array. E.g. for me it contained ['JavaEmbeddedFrame', 'Wine', 'Update-notifier']
and I modified it to ['JavaEmbeddedFrame', 'Wine', 'Update-notifier', 'Autokey']
. If you are using Unity2D then this won't solve the problem because of a bug in Unity2D. For Unity2D you have to change the array to ['all']
to whitelist every app. After these modifications log-out/log-in and the tray icon should be visible now.
Don't forget to set autokey
to start up on login, on the Edit->Preferences->General
tab.
Solution 2:
Personally I've found ClipIt to cover all my copy/paste needs.
sudo apt-get install clipit
With it's hotkey combinations you can pretty much get to any paste item super quickly. I have set Ctrl+Alt+H to "manage history" which allows me to instantly launch a floating window, type a search for the item I want to paste and paste it directly into whatever window I'm in (make sure "Automatically paste selected item" is checked in Preferences > Settings).
There's also the fast access "Manage hotkey" which shows you a list of the most recent 20 clips for quick access. If the items you're pasting are used commonly they'll be in your history.
If you're not pasting them that commonly you could use ClipIt's "Actions" feature to place items into the clipboard quickly.
For example, in actions you could add:
Action: test
Command: clipit "this is a test line to be pasted"
You can then run the actions hotkey (default ctrl+alt+a), select your command title, and then ctrl+v to paste.
Works pretty sweetly. Sadly I haven't worked out how to make the action auto-paste into the current window. I tried piping to xclip -o but that doesn't work.