将某些内容复制到剪贴板(使用 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)