Xsel eignet sich hervorragend.
Es handelt sich (bei diesem hier) um ein Script, muß nicht installiert werden.
siehe Anhang !
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- access X selection from command line
s a quick hack to give access to the X selection from the command line.
n paste stuff from the X selection to stdout and copy stuff from stdin to X selecti
examples:
p | less # pastes the current X selection to less
-paste | less # same as above
uppa | xsel -c # 'puppa' is now the current X selection
uppa | xsel --copy # same as above
c "puppa" # same as above
uppa | xsel -m # 'puppa' merged to the current X selection
uppa | xsel --merge # same as above
m "puppa" # same as above
ove examples should also give you complete understanding of the xsel syntax
.
r options:
c -display host3:0.0 "puppa" #Use X server on host3:0.0
c -s CLIPBOARD "puppa" #Use CLIPBOARD selection rather than PRIMARY
#You may use PRIMARY, SECONDARY or
#CLIPBOARD - also abbreviations
#P,p,S,s,C and c are valid.
c --selection CLIPBOARD "puppa" #Same as -s.
Note that the X selection model has no concept of selection buffer on the server.
Rather, the client that holds the current selection makes it available to the other
clients and has to wait until someone requests it. Hence, xsel forks and serves the
selection requests until someone else claims the selection.
xsel.c is completely based on the Xfree86 xcutsel.c. Its author, Ralph Swick, deser
more credit than I do.
What is it good for?
I originally began implementing this to able to select a word in X (in any applicat
and get the Finnish-English/English-Finnish translation for it. I've put the follow
hacks in the Enlightenment shortcuts configuration:
* winkey-f1: dict.pl `xsel -p` | gmessage -nearmouse -geometry 440x300 -file -
(dict.pl is a perl script that fetches the translation from a web service
(now that Mofile no longer provides this service, I use Kielikone's Netmot th
is a commercial (non-free) service.))
* winkey-f2: netscape-communicator -remote "openURL(`xsel -p`, new-window)"&
Select an URL and open a netscape window for it with one key press.
* winkey-f3: netscape-communicator -remote "openURL
(http://www.google.com/search?q=`xsel -p|perl -pe 'tr/ /+/'`, new-window)"&
Select a word and execute a Google search for it.
and so on. (I modified gmessage to exit on esc key press, and make selecting text p
The diff is available below. You can use standard xmessage as well.)
You could also do something like
locate file | xsel -c
to get a large file listing into any application via X selection.
Download
* Source: xsel.c 0.04.1
* Man page: xsel.man 0.04.1
* Linux x86 redhat-6.2 binary for Xfree-4.0: xsel
* modified gmessage source: gmessage.c and the diff to gmessage-0.2
* Linux x86 redhat-6.2 gmessage binary
To compile: gcc xsel.c -O2 -o xsel -lX11 -lXt -lXaw -L/usr/X11R6/lib/
gcc `gtk-config --cflags` -O6 gmessage.c -o gmessage `gtk-config --libs`
(Too lazy to hack up a Makefile).
Versions
* 0.01 13082000 vherva: Initial version
* 0.02 14082000 vherva: Fixed -display command line switch. Fixed a hang with -
empty selection. Some clean-ups.
* 0.03 11062001 vherva: use XSetWMHints to start the program in iconic mode.
This workarounds (or fixes, depending on how do you look at it) the orphaned
window behaviour some folks were seeing. (You do get an entry to the KDE task
but that can be seen as useful, hence I'm lazy fix it.)
* 0.04 21072002 vherva: Add --merge, --selection and clean up.
* 0.04.1 30112002 vherva: Fix a typo in WriteStdout() - thanks to José Fonseca
<j_r_fonseca@yahoo.co.uk>
Bugs
Xsel sometimes opens a small window that is not always visible. With my configurati
never shows up, so I'm not eager enough to figure out how to get rid of it.
Contact
**********
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gruß, Tom