在linux上轻松实现多个剪贴板

时间:2017-08-05 08:54:04

标签: linux clipboard

我需要一个功能,让我有一些剪贴板。

就像我在Calc文档中有三列一样。姓名,电话号码。

我想将名称复制到 ctrl + c 并将其粘贴到 ctrl + v 上,和来自 ctrl + d 的姓氏副本,并粘贴 ctrl + f 等等...

任何想法的人?

1 个答案:

答案 0 :(得分:0)

To my knowledge, there is no easy way to have such a feature, without writing some code of your own, since clipboard behavior depends on the application. Also there is no software (at least for my distro), that implements these shortcuts.

But it is not entirely impossible, albeit a bit hack-y. Here is my idea:

Since you only need three separate clipboards, you're in luck, since there is technically three selections in GNU/Linux:

  1. PRIMARY
  2. SECONDARY
  3. CLIPBOARD

While the way they are used is defined by application, you can try force-writing to them. So, for example, if you wold like to occupy SECONDARY selection, something like this should do the trick:

xsel -o | xsel -s

Or for CLIPBOARD:

xsel -o | xsel -b

Now, pasting is a bit more tricky. AFAIK xsel and xclip can only write the selection to standard output. So, probably, the only option of pasting would be to overwrite one of the selections. Preferably the CLIPBOARD one, so you can simply ctrl + v in Calc.

As for adding actual keyboard shortcuts, that depends on what DE you are using. Typically, keyshorts are located in the system or keyboard settings of most DEs.