我曾经使用过来自windowmaker的实用程序wxcopy和wxpaste,但是最近的Linux版本(或X版本)似乎已经破坏了它们-我怀疑安全性得到了加强,并且尚未进行更新以匹配它们。例如,您可以执行以下操作:
echo fred | wxcopy | tr "a-z" "A-Z" | wxpaste
获得输出FRED。(这是一个人为的示例,因为如果没有最终的wxpaste,您将得到相同的结果,但是我认为它具有您可以实现的目标。)
但是,您可以使用“ xcb”包实现相同的效果,该包非常轻巧,并且还提供了8个剪贴板的微小(汇总)可视化显示。
几年前,我写了一对wcopy / wpaste的shell脚本,以使wxcopy / wxpaste看起来更令人愉快。我今晚更新了它们,以使用wxcopy / wxpaste或xcb。这使它们比需要的复杂一些,但是我将其粘贴到此处-希望它们对这个论坛不太长。
这是wcopy:
#!/bin/sh
#
# Provide some enhancements to the wxcopy command, which copies standard input
# to an X11 clipboard text buffer.
#
# Allow copying from stdin to any of the cutbuffers. Note that they are
# indexed counting from 0.
#
# Author: Luke Kendall
#
if [ `uname -s` = "Darwin" ]
then
WXCOPY=pbcopy
WXPASTE=pbpaste
else
WXCOPY=wxcopy
WXPASTE=wxpaste
BUFSPEC="-cutbuffer"
xcb -p 0 > /tmp/wc$$
if echo "fred$$" | wxcopy -cutbuffer 0 && [ `wxpaste` = "fred$$" ]
then
: # Great, they're actually working. Not common on modern Linuxes.
echo "working" > $HOME/.wcopyok
else
rm -f $HOME/.wcopyok
WXCOPY="xcb -s"
WXPASTE="xcb -p"
BUFSPEC=
fi
xcb -s 0 < /tmp/wc$$
fi
unset WXARGS
if [ $# = 0 ]
then
$WXCOPY ${WXCOPY_DEFS:-0}
else
MYNAME=`basename $0`
USAGE="usage: $MYNAME [ [0-9]... ] [$WXCOPY's args]"
numlist=true
for n
do
if $numlist && expr "x$n" : 'x[0-9][0-9]*$' > /dev/null
then
NUMARGS="$NUMARGS $n"
else
numlist=false
if [ "x$n" = "x-h" ]
then
echo "$USAGE" >&2
exit 0
else
WXARGS="$WXARGS $n"
fi
fi
done
set - $NUMARGS
$WXCOPY $WXCOPY_DEFS $WXARGS $BUFSPEC $1
ORIG="$1"
shift
for n
do
$WXPASTE $BUFSPEC $ORIG | $WXCOPY $WXCOPY_DEFS $WXARGS $BUFSPEC $n
done
fi
这是wpaste:
#!/bin/sh
#
# Provide some enhancements to the wxpaste command, which pastes from X11
# clipboard text buffers to standard output.
#
# Allow pasting to stdout from any of the cutbuffers. Note that they are
# indexed counting from 0.
#
# Author: Luke Kendall
#
if [ `uname -s` = "Darwin" ]
then
WXCOPY=pbcopy
WXPASTE=pbpaste
else
WXCOPY=wxcopy
WXPASTE=wxpaste
BUFSPEC="-cutbuffer"
if [ -s $HOME/.wcopyok ]
then
: # Great, they're actually working. Not common on modern Linuxes.
else
WXCOPY="xcb -s"
WXPASTE="xcb -p"
BUFSPEC=
fi
fi
if [ $# = 0 ]
then
$WXPASTE ${WXPASTE_DEFS:-0}
else
MYNAME=`basename $0`
USAGE="usage: $MYNAME [ [0-9]... ] [$WXPASTE's args]"
for n
do
if expr "x$n" : 'x[0-9][0-9]*$' > /dev/null
then
NUMARGS="$NUMARGS $n"
elif [ "x$n" = "x-h" ]
then
echo "$USAGE" >&2
exit 0
else
WXARGS="$WXARGS $n"
fi
done
set - $NUMARGS
: echo "Num args: $#"
for n
do
: echo "Doing: $WXPASTE $WXPASTE_DEFS $WXARGS $BUFSPEC $n"
$WXPASTE $WXPASTE_DEFS $WXARGS $BUFSPEC $n
done
fi
如果有人感兴趣,我也为脚本编写了手册页-但是您可以通过搜索wcopy.1x和wpaste.1x来找到它们(它们仍然有效)。
xclip -sel clip
。我个人使用,所有的时间