Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How do I access the Shift-Insert (paste) clipboard from a script? You can see what I use here.

Edit: A demonstration how it works, with xclip:

echo hello | xclip -selection secondary
xclip -o -selection secondary

Edit 2: Just implemented the solution below. This will make my life so much easier so I thought I'd share it.

First, the script pst:

#!/bin/zsh

echo -n `xclip -d ":0" -o -selection clipboard`

then, in .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) )

Now, in any tty, paste with pst, in Emacs (anywhere, but specifically in a tty, as in X, you already have Shift-Insert) M-x pst.

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

xclip will allow you to access the PRIMARY, SECONDARY, and CLIPBOARD selections, choosing which one with the -selection option.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.