xclip is a command line interface to the X11 selections (X11 clipboard). It can also be used for copying files, as an alternative to sftp/scp, thus avoiding password prompts when X11 forwarding has already been setup. xclip reads from Standard Input or from one or more files and copy it to the X11 clipboard making it available to the X applications. xclip can also print the content of the current X clipboard onto the standard output or to a file.
Install xclip in openSUSE
To install xclip in openSUSE, click this 1-click installer from Packman supported on openSUSE 11.1/11.0/10.3
This should download the YMP file and automatically launch the YaST package manager to add the required Repositories, download and install xclip and the dependencies. Click next on the xclip installation screen and Next again on the installation proposal window. This should start adding the required repositories, download and install xclip and its required dependencies. Click Finish when the installation completes successfully.
This should install xclip under
and adds a man page as well.
To browse a quick list of options available for xclip
sai@saihari:~ > xclip -h
Usage: xclip [OPTION] [FILE]…
Access an X server selection for reading or writing.
-i, -in read text into X selection from standard input or files
-o, -out prints the selection to standard out (generally for
piping to a file or program)
-l, -loops number of selection requests to wait for before exiting
-d, -display X display to connect to (eg localhost:0″)
-h, -help usage information
-selection selection to access (“primary”, “secondary”, “clipboard” or “buffer-cut”)
-noutf8 don’t treat text as utf-8, use old unicode
-version version information
-silent errors only, run in background (default)
-quiet run in foreground, show what’s happening
-verbose running commentary
Report bugs to <email@example.com>
A simple example to demonstrate how xclip works, we here copy the output of the command “uname -a” directly onto the X clipboard by piping its output to the xclip utility.
sai@saihari:/usr/share/man> uname -a | xclip
Now, open an X application like openoffice and paste the contents by right-click and paste or simply clicking the middle button. This is equivalent to using the -i option (default).
To read a file and make it available to X clipboard:
This copies the contents of the file /etc/hosts onto the x clipboard.
To copy the current contents on the X clipboard onto the standard out or even to a file
sai@saihari:/usr/share/man> xclip -o
This displays the current X clipboard content onto the terminal (standard out)
To copy the X clipboard contents to a file
sai@saihari:/usr/share/man> xclip -o ~/clipfile.txt
This copies the X clipboard contents onto a file called clipfile.txt under my home directory.
Click here to visit the project homepage
I found that xsel, http://www.vergenet.net/~conrad/software/xsel/, worked better than xclip for me.