1

Is there a command for pasting what is in clipboard?
I need a command that does the same thing as to press Ctrl+V.

I tried a few options for xclip, but they don't paste normally and need middle click or so.

zx485
  • 2,426
  • Your question above and your comment in reply to @konapun's anwser seem to contradict each other. Apart from that the answer to your question would be xsel -o -b (for pasting the 'normal' clipboard to standard out, as via Ctrl+V) or xsel -o (for the X clipboard, which you could also paste via a middle-click of the mouse). – ᴠɪɴᴄᴇɴᴛ Aug 06 '14 at 10:24
  • xsel -o -b does not work outside a terminal. – Minimus Heximus Aug 06 '14 at 10:38
  • Then I'm afraid I still don't understand your question ... why can't you use Ctrl+V itself? – ᴠɪɴᴄᴇɴᴛ Aug 06 '14 at 10:52
  • 1
    because I'll use a command to do it. commands do not have hands to type. btw, this question is obsolete for me. I wanted to set a hotkey which copies date and time and then pastes it immediately. Now it's implemented somehow: Cha, 93/05/15, 15:34:14 (local time). Now it works without bothering clipboard. Cha, 93/05/15, 15:36:49 – Minimus Heximus Aug 06 '14 at 11:04
  • 1
    Glad you found a solution. With a 'command' I guess you mean a shell script? For other people having the same question: date | xclip && xclip -o. – ᴠɪɴᴄᴇɴᴛ Aug 06 '14 at 11:13
  • 2
    yes shell script or something to be fed in a Run Window. But for date I suggest: xdotool type " $(date) ". It may also need a command to change keyboard layout to English. – Minimus Heximus Aug 06 '14 at 11:23

3 Answers3

3

Klipper

The Kubuntu is using as default the Klipper. KDE UserBase: http://userbase.kde.org/Klipper

As a KDE/Qt application the Klipper can be used via the qdbus: http://manpages.ubuntu.com/manpages/trusty/man1/qdbus.1.html

Available commands can be viewed with the qdbusviewer:

enter image description here

or with the terminal (konsole):

:~$ qdbus org.kde.klipper /klipper
method void org.kde.klipper.klipper.clearClipboardContents()
method void org.kde.klipper.klipper.clearClipboardHistory()
method QString org.kde.klipper.klipper.getClipboardContents()
method QString org.kde.klipper.klipper.getClipboardHistoryItem(int i)
method QStringList org.kde.klipper.klipper.getClipboardHistoryMenu()
method void org.kde.klipper.klipper.saveClipboardHistory()
method void org.kde.klipper.klipper.setClipboardContents(QString s)
method void org.kde.klipper.klipper.showKlipperManuallyInvokeActionMenu()
method void org.kde.klipper.klipper.showKlipperPopupMenu()
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface_name, QString property_name)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface_name)
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)
method QString org.freedesktop.DBus.Introspectable.Introspect()
method QString org.freedesktop.DBus.Peer.GetMachineId()
method void org.freedesktop.DBus.Peer.Ping()

The command

qdbus org.kde.klipper /klipper getClipboardContents

will get the last line from the clipboard.

The command can added to the KDE menu (http://docs.kde.org/development/en/kde-workspace/kmenuedit/index.html) and called with the keyboard shortcut or to the file manager context menu (KDE service menu - http://techbase.kde.org/Development/Tutorials/Creating_Konqueror_Service_Menus).

enter image description here

Other options for the clipboard managers: http://qt-apps.org/content/show.php/CopyQ?content=147452

user26687
  • 14,934
  • qdbus org.kde.klipper /klipper getClipboardContents gives an error for me: qdbus: could not exec '/usr/lib/i386-linux-gnu/qt5/bin/qdbus': No such file or directory something is missing! – Minimus Heximus Dec 21 '13 at 10:47
  • As default the KDE 4 is using the Qt 4. Sometimes the upgrade will mess the things: https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1175251 – user26687 Dec 21 '13 at 11:11
0

Yes, install the package xsel

xsel --clipboard will paste the clipboard contents.

konapun
  • 356
  • 2
  • 14
  • 1
    You might want to add that you can install it from here, and that you can also use xsel -b ;-) – Wilf Dec 20 '13 at 18:16
  • Unfortunately this command just prints the clipboard content in terminal. Outside it, it does not work. I want to assign a hotkey to run such a command (along with other ones) to work the same as Ctrl+V. – Minimus Heximus Dec 20 '13 at 18:18
  • Where are you wanting it to paste? A nonactive window? – konapun Dec 20 '13 at 18:22
  • @konapun: everywhere an editing area is focused. for example in this comment. I need a command that will be run without any terminal window open using a hotkey. – Minimus Heximus Dec 20 '13 at 18:26
  • 1
    Are you looking for something more like a macro recorder/player? If so, you may want to check out autokey – konapun Dec 20 '13 at 18:43
0

Open your terminal and type as

nano .bashrc

then

paste a line as

xclip="xclip -selection c" 

then save & close with Ctrl+X+Y .

Then type bash

then on wards you can use Ctrl+V to paste.

Raja G
  • 102,391
  • 106
  • 255
  • 328