how to swap clipboard content with selection upon keyboard shortcut

后端 未结 3 1856
野趣味
野趣味 2021-01-16 13:28

I\'d like to exchange the currently selected text in eclipse (or even any program) on linux with the content of the clipboard when pressing a shortcut like Ctrl-B. Any ideas

3条回答
  •  终归单人心
    2021-01-16 14:16

    With xclip, these three steps can be performed (read > as "replaces"):

    • Primary > Secondary
    • Cliboard > Primary
    • Secondary > Clipboard

    Since no program ever uses it, we use Secondary as a temporary slot to swap Clipboard with Primary.

    xclip -o -sel p|xclip -i -sel s
    xclip -o -sel c|xclip -i -sel p
    xclip -o -sel s|xclip -i -sel c
    

    Make the script executable with chmod +x script and now you can bind a shortcut to it.

提交回复
热议问题