Conrad Parker |
XSel |
[ Introduction | Advanced features | Usage manual | Download | Standards | License | Contact ]
Latest version: 1.2.0
XSel is a command-line program for getting and setting the contents of the X selection. Normally this is only accessible by manually highlighting information and pasting it with the middle mouse button.
xsel < file
after which you can paste the file's contents into any X application with the middle mouse button, as though you had highlighted its text. xsel will read in the file contents exactly, whereas manual highlighting invariably breaks lines and transforms tabs into spaces. This is especially handy for copying in large files.
xsel > file
after which file will contain exactly the contents of the X selection, without trailing newlines and spaces and crap.
XSel is more than just cat for the X selection.
xsel --append < file
xsel --follow < file
to make the X selection follow standard input as it grows (like tail -f).
XSel also lets you access some of the more esoteric features of the X selection:
xsel --delete
Will cause the program in which text is selected to delete that text. This really works, you can try it on xedit to remotely delete text in the editor window.
The X Window System maintains two selections, the usual primary selection and a secondary, which isn't used much ... XSel lets you use the secondary selection, for example:
xsel --secondary < file
xsel --secondary > file
xsel --exchange
So for example you can store useful text in the secondary selection and retrieve it later.
Similarly, X has a clipboard selection. You can use the standard xclipboard program to manage a history of selected text, and you can use xsel to actually get text into that clipboard:
xsel --clipboard < file
Normally the X selection only exists as long as the program it was selected in is running. Further, some buggy applications tend to forget their selection text after a little while. If you run:
xsel --keep
after selecting some important text, xsel will copy the text into its own memory so you can paste it elsewhere even if the original program exits or crashes.
Naturally all these options have single character equivalents, and xsel --help provides usage information. For complete details, see the xsel man page.
apt-get install xsel
or a similar command will install the xsel package on your system.
XSel is distributed in source form here
(xsel-1.2.0.tar.gz).
git clone git://github.com/kfish/xsel.git
XSel conforms to the X Window System Inter-Client Communication Conventions
Manual Version 2.0 (ICCCM2),
including correct handling of TARGETS, MULTIPLE, TIMESTAMP, and DELETE
targets, INCR properties and large data transfers.
My
thoughts
on ICCCM (Warning: explicit language).
Permission to use, copy, modify, distribute, and sell this software and
its documentation for any purpose is hereby granted without fee, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation. No representations are made about the suitability of this
software for any purpose. It is provided "as is" without express or
implied warranty.
Please direct any queries, bug reports etc. about XSel to the author,
Conrad Parker conrad@vergenet.net .
Copyright © 1995-2010 Conrad Parker <conrad@vergenet.net>.
Last modified Sun Nov 21 2010Download
XSel is available in most distributions.
Source tarballs
Development versions are available via Git
Debian package info for xsel
Standards
X11 ICCCM2
Articles and discussion
License
Copyright (C) 2001 Conrad Parker <conrad@vergenet.net>
Contact