Ema*_*erg 2 linux scripting clipboard
如何从脚本访问 Shift-Insert(粘贴)剪贴板?你可以在这里看到我使用的东西。
编辑:演示它是如何工作的,包括xclip
:
echo hello | xclip -selection secondary
xclip -o -selection secondary
Run Code Online (Sandbox Code Playgroud)
编辑 2:刚刚实施了下面的解决方案。这将使我的生活变得更轻松,所以我想我会分享它。
首先,脚本pst
:
#!/bin/zsh
echo -n `xclip -d ":0" -o -selection clipboard`
Run Code Online (Sandbox Code Playgroud)
然后,在.emacs
:
(defun pst ()
"Inserts the X clipboard (xclip -d :0 -o -selection clipboard) at
point. `M-1' (the '(1)) to insert in the current buffer."
(interactive)
(shell-command "pst" '(1))
(end-of-line) )
Run Code Online (Sandbox Code Playgroud)
现在,在任何 tty 中,粘贴pst
, 在 Emacs 中(任何地方,但特别是在 tty 中,如在 X 中,您已经有了 Shift-Insert)M-x pst
。