有两个命令行工具(在两个不同的包中)可以访问 X 剪贴板:
xclip
xsel
我很想知道这两者之间的区别,并听取建议在哪些情况下使用哪个。
当我从 Windows 机器到 linux(没有安装 X11)使用 putty 时,是否有 xsel 或 xclip 的替代方案?xclip/xsel 需要 X11。我想将完整的 shell 命令输出通过管道传输到剪贴板,然后将其粘贴到 Windows 框上到应用程序。我不想在那些 linux 服务器上安装 xsel 和 xclip 需要的所有 X11 依赖项。这可能吗?担
将某些内容复制到剪贴板(使用 ctrl+c)后,我想要一个脚本(bash、python 或任何其他语言)自动检测新条目已添加到剪贴板,更改其内容并将其放回剪贴板,以便在粘贴时我得到修改后的文本。该脚本应不断在后台运行并监视剪贴板的变化。
以下脚本描述了所需的修改:
来源:https : //superuser.com/questions/796292/is-there-an-efficient-way-to-copy-text-from-a-pdf-without-the-换行
#!/bin/bash
# title: copy_without_linebreaks
# author: Glutanimate (github.com/glutanimate)
# license: MIT license
# Parses currently selected text and removes
# newlines that aren't preceded by a full stop
SelectedText="$(xsel)"
ModifiedText="$(echo "$SelectedText" | \
sed 's/\.$/.|/g' | sed 's/^\s*$/|/g' | tr '\n' ' ' | tr '|' '\n')"
# - first sed command: replace end-of-line full stops with '|' delimiter and keep original periods.
# - second sed command: replace empty lines with …
Run Code Online (Sandbox Code Playgroud)